From patchwork Wed Oct 26 08:51:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1/2] zdtm: Write .inprogress pidfile From: Pavel Emelyanov X-Patchwork-Id: 2227 Message-Id: <58106E91.2030205@virtuozzo.com> To: CRIU Date: Wed, 26 Oct 2016 11:51:29 +0300 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 --- 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 acf4a31..fa6ee86 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 db7118d..a3576a5 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 8a6f6ba..3f9f550 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