]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: avoid data race
authorEric Blake <eblake@redhat.com>
Wed, 15 Dec 2010 17:23:32 +0000 (10:23 -0700)
committerEric Blake <eblake@redhat.com>
Mon, 20 Dec 2010 17:29:50 +0000 (10:29 -0700)
I got some spurious failures when commandhelper won the race and
ran to the point of parent detection prior to the intermediate
daemonizing process getting a chance to exit.  This fixes it.

* tests/commandhelper.c (main): Checking for re-parenting to
init(1) is racy; instead check that we belong to a new session.

tests/commandhelper.c

index 5b2f301f2ccaf5b57e1dbf624d4be359af624c57..f400e8d2f6907e8798aeaed151e2cc3f00a29251 100644 (file)
@@ -95,7 +95,7 @@ int main(int argc, char **argv) {
             fprintf(log, "FD:%d\n", i);
     }
 
-    fprintf(log, "DAEMON:%s\n", getppid() == 1 ? "yes" : "no");
+    fprintf(log, "DAEMON:%s\n", getpgrp() == getsid(0) ? "yes" : "no");
     char cwd[1024];
     if (!getcwd(cwd, sizeof(cwd)))
         return EXIT_FAILURE;