diff --git a/criu/util.c b/criu/util.c index 59643f88b..6fa0ab05f 100644 --- a/criu/util.c +++ b/criu/util.c @@ -1459,3 +1459,12 @@ int getpid() { return syscall(__NR_getpid); } + +/* + * In glibc 2.24, fork() may fail when parent and child are + * from different pid namespaces and have the same pid. + */ +pid_t fork() +{ + return (pid_t)syscall(__NR_clone, SIGCHLD, 0, NULL, 0, NULL); +} diff --git a/test/zdtm/lib/test.c b/test/zdtm/lib/test.c index 562fa56c6..b332cba0d 100644 --- a/test/zdtm/lib/test.c +++ b/test/zdtm/lib/test.c @@ -296,3 +296,13 @@ void test_waitsig(void) { futex_wait_while(&sig_received, 0); } + +pid_t fork() +{ + return (pid_t)syscall(__NR_clone, SIGCHLD, 0, NULL, 0, NULL); +} + +int getpid() +{ + return syscall(__NR_getpid); +}