diff options
| author | Vladimir Kotal <Vladimir.Kotal@Sun.COM> | 2009-09-15 20:20:20 +0200 |
|---|---|---|
| committer | Vladimir Kotal <Vladimir.Kotal@Sun.COM> | 2009-09-15 20:20:20 +0200 |
| commit | 44991a1c1bb35cccb6bf99cb6dce14864dcee19c (patch) | |
| tree | e43389c0b05fa250ba59ff5a593557f7e2446ef5 /usr/src/cmd/rmvolmgr/rmvolmgr.c | |
| parent | 9d48f5d37dfc1f8378818cf3d2baa2ccf7990c38 (diff) | |
| download | illumos-joyent-44991a1c1bb35cccb6bf99cb6dce14864dcee19c.tar.gz | |
PSARC/2009/444 daemon() in libc
4471189 should have 4.4BSD's daemon() utility function
Diffstat (limited to 'usr/src/cmd/rmvolmgr/rmvolmgr.c')
| -rw-r--r-- | usr/src/cmd/rmvolmgr/rmvolmgr.c | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/usr/src/cmd/rmvolmgr/rmvolmgr.c b/usr/src/cmd/rmvolmgr/rmvolmgr.c index 3475066a97..3587d77dfd 100644 --- a/usr/src/cmd/rmvolmgr/rmvolmgr.c +++ b/usr/src/cmd/rmvolmgr/rmvolmgr.c @@ -74,7 +74,6 @@ static boolean_t opt_s; /* system instance */ static boolean_t rmm_prop_eject_button = B_TRUE; static void get_smf_properties(); -static int daemon(int nochdir, int noclose); static void rmm_device_added(LibHalContext *ctx, const char *udi); static void rmm_device_removed(LibHalContext *ctx, const char *udi); static void rmm_property_modified(LibHalContext *ctx, const char *udi, @@ -594,50 +593,6 @@ rmm_unmount_all() } } -static int -daemon(int nochdir, int noclose) -{ - int fd; - - switch (fork()) { - case -1: - return (-1); - case 0: - break; - default: - exit(0); - } - - if (setsid() == -1) - return (-1); - - if (!nochdir) - (void) chdir("/"); - - if (!noclose) { - struct stat64 st; - - if (((fd = open("/dev/null", O_RDWR, 0)) != -1) && - (fstat64(fd, &st) == 0)) { - if (S_ISCHR(st.st_mode) != 0) { - (void) dup2(fd, STDIN_FILENO); - (void) dup2(fd, STDOUT_FILENO); - (void) dup2(fd, STDERR_FILENO); - if (fd > 2) - (void) close(fd); - } else { - (void) close(fd); - (void) __set_errno(ENODEV); - return (-1); - } - } else { - (void) close(fd); - return (-1); - } - } - return (0); -} - int main(int argc, char **argv) { |
