char *buffers[3] = {NULL, NULL, NULL};
size_t buflen[3] = {0, 0, 0};
char c;
+ bool daemonize_check = false;
+ size_t daemonize_retries = 3;
if (!log)
return ret;
sscanf(argv[i], "%u%c", &readfds[numreadfds++], &c) != 1) {
printf("Could not parse fd %s\n", argv[i]);
goto cleanup;
+ } else if (STREQ(argv[i], "--check-daemonize")) {
+ daemonize_check = true;
}
}
fprintf(log, "FD:%zu\n", i);
}
- fprintf(log, "DAEMON:%s\n", getpgrp() != getppid() ? "yes" : "no");
+ while (true) {
+ bool daemonized = getpgrp() != getppid();
+
+ if (daemonize_check && !daemonized && daemonize_retries-- > 0) {
+ usleep(100*1000);
+ continue;
+ }
+
+ fprintf(log, "DAEMON:%s\n", daemonized ? "yes" : "no");
+ break;
+ }
+
if (!(cwd = getcwd(NULL, 0)))
goto cleanup;
if (strlen(cwd) > strlen(".../commanddata") &&
*/
static int test4(const void *unused G_GNUC_UNUSED)
{
- virCommandPtr cmd = virCommandNew(abs_builddir "/commandhelper");
+ virCommandPtr cmd = virCommandNewArgList(abs_builddir "/commandhelper",
+ "--check-daemonize", NULL);
char *pidfile = virPidFileBuildPath(abs_builddir, "commandhelper");
pid_t pid;
int ret = -1;