diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2001-07-02 13:59:16 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2001-07-02 13:59:16 +0000 |
commit | e91406e14bbb0988b374ee6d7740935c5d63e658 (patch) | |
tree | 52729128f33cf2b23849641c0f6788ce8b4a18e2 /usr.bin/ssh/serverloop.c | |
parent | e72e204cf708481e6c6627d7f6ef29bb0a61a59d (diff) |
wait until !session_have_children(); bugreport from Lutz.Jaenicke@aet.TU-Cottbus.DE
Diffstat (limited to 'usr.bin/ssh/serverloop.c')
-rw-r--r-- | usr.bin/ssh/serverloop.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/usr.bin/ssh/serverloop.c b/usr.bin/ssh/serverloop.c index cc089f326b8..c5ef95b7061 100644 --- a/usr.bin/ssh/serverloop.c +++ b/usr.bin/ssh/serverloop.c @@ -35,7 +35,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: serverloop.c,v 1.72 2001/06/27 02:12:52 markus Exp $"); +RCSID("$OpenBSD: serverloop.c,v 1.73 2001/07/02 13:59:14 markus Exp $"); #include "xmalloc.h" #include "packet.h" @@ -703,11 +703,25 @@ server_loop2(Authctxt *authctxt) if (writeset) xfree(writeset); - channel_free_all(); - signal(SIGCHLD, SIG_DFL); + while ((pid = waitpid(-1, &status, WNOHANG)) > 0) session_close_by_pid(pid, status); + /* + * there is a race between channel_free_all() killing children and + * children dying before kill() + */ + channel_free_all(); + + while (session_have_children()) { + pid = waitpid(-1, &status, 0); + if (pid > 0) + session_close_by_pid(pid, status); + else { + error("waitpid returned %d: %s", pid, strerror(errno)); + break; + } + } } static void |