]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: commandhelper: change how we detect if running as daemon
authorPavel Hrdina <phrdina@redhat.com>
Wed, 27 May 2020 11:37:54 +0000 (13:37 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Fri, 10 Jul 2020 07:40:55 +0000 (09:40 +0200)
The old code works correctly with make and running directly from shell
but it failed with Meson test suite where session ID and process group
are the same in both cases.

What changes in both cases is parent process ID so use that instead of
session ID.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/commandhelper.c

index 3f040be8f22dd41294e684930870d99d9a90cf51..4266e11902ffcff127629477eff2b4a403cdb3cd 100644 (file)
@@ -126,7 +126,7 @@ int main(int argc, char **argv) {
             fprintf(log, "FD:%zu\n", i);
     }
 
-    fprintf(log, "DAEMON:%s\n", getpgrp() == getsid(0) ? "yes" : "no");
+    fprintf(log, "DAEMON:%s\n", getpgrp() != getppid() ? "yes" : "no");
     if (!(cwd = getcwd(NULL, 0)))
         goto cleanup;
     if (strlen(cwd) > strlen(".../commanddata") &&