summaryrefslogtreecommitdiff
path: root/usr.bin/ssh
diff options
context:
space:
mode:
authorDug Song <dugsong@cvs.openbsd.org>1999-10-17 20:43:32 +0000
committerDug Song <dugsong@cvs.openbsd.org>1999-10-17 20:43:32 +0000
commite8a80e10e2603f66318c266d38859ffc443fdf9a (patch)
tree332d926dd7ac66c5f95a30e8b3ef9f5f14c439ed /usr.bin/ssh
parent30e18f6a35f57abe653fbebfcd27ba07b8e7da76 (diff)
use daemon()
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r--usr.bin/ssh/sshd.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/usr.bin/ssh/sshd.c b/usr.bin/ssh/sshd.c
index 0b68143dc47..3629b83e415 100644
--- a/usr.bin/ssh/sshd.c
+++ b/usr.bin/ssh/sshd.c
@@ -18,7 +18,7 @@ agent connections.
*/
#include "includes.h"
-RCSID("$Id: sshd.c,v 1.35 1999/10/17 20:39:11 dugsong Exp $");
+RCSID("$Id: sshd.c,v 1.36 1999/10/17 20:43:31 dugsong Exp $");
#include "xmalloc.h"
#include "rsa.h"
@@ -369,16 +369,9 @@ main(int ac, char **av)
#ifdef TIOCNOTTY
int fd;
#endif /* TIOCNOTTY */
-
- /* Fork, and have the parent exit. The child becomes the server. */
- if (fork())
- exit(0);
-
- /* Redirect stdin, stdout, and stderr to /dev/null. */
- freopen("/dev/null", "r", stdin);
- freopen("/dev/null", "w", stdout);
- freopen("/dev/null", "w", stderr);
-
+ if (daemon(0, 0) < 0)
+ fatal("daemon() failed: %.200s", strerror(errno));
+
/* Disconnect from the controlling tty. */
#ifdef TIOCNOTTY
fd = open("/dev/tty", O_RDWR|O_NOCTTY);
@@ -388,7 +381,6 @@ main(int ac, char **av)
close(fd);
}
#endif /* TIOCNOTTY */
- (void)setsid();
}
/* Reinitialize the log (because of the fork above). */