VirtualBox

Changeset 6149 in vbox


Ignore:
Timestamp:
Dec 19, 2007 9:42:02 AM (17 years ago)
Author:
vboxsync
Message:

Solaris VBoxService daemon fix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxService-solaris.cpp

    r6144 r6149  
    5858        return -1;
    5959
    60     int pid = fork();
     60    pid_t pid = fork();
    6161    if (pid < 0)         /* The fork() failed. Bad. */
    6262        return -1;
     
    6969     * rid of signals, file descriptors & other stuff we inherited from the parent.
    7070     */
    71     setsid();
     71    pid_t newpgid = setsid();
     72    if (newpgid < 0)     /* Failed to create new sesion */
     73        return -1;
    7274
    73     /* Close all or only standard streams */
    74     int size = noclose ? getdtablesize() : 2;
    75     for (int i = size; i >= 0; i--)
    76         close(i);
    77 
    78     /* Open stdin(0), stdout(1) and stderr(2) to /dev/null */
    79     int fd = open("/dev/null", O_RDWR);
    80     dup(fd);
    81     dup(fd);
     75    /* BSD daemon style. */
     76    if (!noclose)
     77    {
     78        /* Open stdin(0), stdout(1) and stderr(2) to /dev/null */
     79        int fd = open("/dev/null", O_RDWR);
     80        dup2(fd, STDIN_FILENO);
     81        dup2(fd, STDOUT_FILENO);
     82        dup2(fd, STDERR_FILENO);
     83        if (fd > 2)
     84            close(fd);
     85    }
    8286
    8387    /* Switch our current directory to root */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette