From 27a481c88855faa10c6f85b8fbca7e5de5ce73be Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Wed, 26 Oct 2016 11:51:00 +0300 Subject: [PATCH] zdtm: Write .inprogress pidfile This one will contain pid of the task living in a sub-ns and waiting for the rest of the test to get daemonized. Signed-off-by: Pavel Emelyanov Acked-by: Tycho Andersen Travised-by: https://travis-ci.org/xemul/criu/builds/170726663 --- test/zdtm/lib/ns.c | 12 ++++++++++++ test/zdtm/lib/test.c | 1 - test/zdtm/lib/zdtmtst.h | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/test/zdtm/lib/ns.c b/test/zdtm/lib/ns.c index acf4a31d8..fa6ee86a4 100644 --- a/test/zdtm/lib/ns.c +++ b/test/zdtm/lib/ns.c @@ -362,6 +362,7 @@ void ns_create(int argc, char **argv) int ret, status; struct ns_exec_args args; int flags; + char *pidf; args.argc = argc; args.argv = argv; @@ -416,6 +417,14 @@ void ns_create(int argc, char **argv) } shutdown(args.status_pipe[0], SHUT_WR); + pidf = pidfile; + pidfile = malloc(strlen(pidfile) + 13); + sprintf(pidfile, "%s%s", pidf, INPROGRESS); + if (write_pidfile(pid)) { + fprintf(stderr, "Preparations fail\n"); + exit(1); + } + status = 1; ret = read(args.status_pipe[0], &status, sizeof(status)); if (ret != sizeof(status) || status) { @@ -428,6 +437,9 @@ void ns_create(int argc, char **argv) exit(1); } + unlink(pidfile); + pidfile = pidf; + if (write_pidfile(pid)) exit(1); diff --git a/test/zdtm/lib/test.c b/test/zdtm/lib/test.c index db7118d05..a3576a573 100644 --- a/test/zdtm/lib/test.c +++ b/test/zdtm/lib/test.c @@ -41,7 +41,6 @@ int test_fork_id(int id) static int cwd = -1; -#define INPROGRESS ".inprogress" static void test_fini(void) { char path[PATH_MAX]; diff --git a/test/zdtm/lib/zdtmtst.h b/test/zdtm/lib/zdtmtst.h index 8a6f6ba89..3f9f55056 100644 --- a/test/zdtm/lib/zdtmtst.h +++ b/test/zdtm/lib/zdtmtst.h @@ -4,6 +4,8 @@ #include #include +#define INPROGRESS ".inprogress" + #ifndef PAGE_SIZE # define PAGE_SIZE (unsigned int)(sysconf(_SC_PAGESIZE)) #endif