create_core should wait for the child to be done writing the core
authorTrond Norbye <trond.norbye@sun.com>
Thu, 17 Dec 2009 09:25:19 +0000 (10:25 +0100)
committerTrond Norbye <trond.norbye@sun.com>
Thu, 17 Dec 2009 09:25:19 +0000 (10:25 +0100)
tests/test.c

index f95141b107ee557db0ee09b85723c8f31ef5a5aa..793bcbd7264d08af68112aefa033e4e931af0980 100644 (file)
@@ -15,6 +15,7 @@
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/wait.h>
 #include <unistd.h>
 #include <time.h>
 #include <fnmatch.h>
@@ -62,8 +63,22 @@ static const char *test_strerror(test_return_t code)
 
 void create_core(void)
 {
-   if (getenv("LIBMEMCACHED_NO_COREDUMP") == NULL && fork() == 0)
-     abort();
+  if (getenv("LIBMEMCACHED_NO_COREDUMP") == NULL)
+  {
+    pid_t pid= fork();
+
+    if (pid == 0)
+    {
+      abort();
+    }
+    else
+    {
+      while (waitpid(pid, NULL, 0) != pid)
+      {
+        ;
+      }
+    }
+  }
 }