From 8175f6e09c5203a3246150bbd06b46a246662794 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 26 Jul 2017 12:41:20 -0700 Subject: [PATCH] libc - Fix bug in rcmdsh() * rcmdsh() (which really nothing should be using any more anyway) used a generic wait(NULL) to wait for a child to exit, but this can wind up waiting for the wrong pid in a multi-threaded or multi-fork environment. * Solved by waiting on the specific pid instead. --- lib/libc/net/rcmdsh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libc/net/rcmdsh.c b/lib/libc/net/rcmdsh.c index 8b4514d5b3..8cf3a16e08 100644 --- a/lib/libc/net/rcmdsh.c +++ b/lib/libc/net/rcmdsh.c @@ -160,7 +160,7 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser, /* Parent. close sp[1], return sp[0]. */ close(sp[1]); /* Reap child. */ - wait(NULL); + waitpid(cpid, NULL, 0); return (sp[0]); } /* NOTREACHED */ -- 2.11.4.GIT