From 630fe36f06658f558ab2c3e6506c1db73a0179ae Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 15 Dec 2010 10:23:32 -0700 Subject: [PATCH] tests: avoid data race 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/commandhelper.c b/tests/commandhelper.c index 5b2f301f2c..f400e8d2f6 100644 --- a/tests/commandhelper.c +++ b/tests/commandhelper.c @@ -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;