summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/serverloop.c
diff options
context:
space:
mode:
authormarkus <markus@openbsd.org>2001-07-02 13:59:14 +0000
committermarkus <markus@openbsd.org>2001-07-02 13:59:14 +0000
commit266c844ebe9c4c44be5c34f5f2e822a1ff62cec1 (patch)
treee358f24138b1d7cf3b4d91dfad8047e2e53681e7 /usr.bin/ssh/serverloop.c
parent#include <string.h> to get mem* prototypes. (diff)
downloadwireguard-openbsd-266c844ebe9c4c44be5c34f5f2e822a1ff62cec1.tar.xz
wireguard-openbsd-266c844ebe9c4c44be5c34f5f2e822a1ff62cec1.zip
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.c20
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