listen1 cleans up its children
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 17 Jun 2014 23:44:04 +0000 (16:44 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 17 Jun 2014 23:44:04 +0000 (16:44 -0700)
tests/listen1.c

index 508e229..7ded55d 100644 (file)
@@ -24,6 +24,9 @@
 #include <ndb.h>
 #include <fcntl.h>
 
+#include <sys/types.h>
+#include <sys/wait.h>
+
 int verbose;
 
 void
@@ -122,6 +125,9 @@ main(int argc, char **argv)
                        fprintf(stderr, "exec: %r\n");
                        exit(1);
                default:
+                       /* reap any available children */
+                       while (waitpid(-1, 0, WNOHANG) > 0)
+                               ;
                        close(nctl);
                        break;
                }