[CRIU] [PATCH] test: remap_dead_pid.c: Fix child PID not being printed

Vitaly Ostrosablin vostrosablin at virtuozzo.com
Thu Jul 20 18:04:01 MSK 2017


There's two issues with this code:

1. Child task is killed by parent faster, than it could print the line.
2. Even if it had time to print it - there would always be 0, because
it's called from child process.

Obviously, this print was meant to be in parent process. So, let's move
it there.

Signed-off-by: Vitaly Ostrosablin <vostrosablin at virtuozzo.com>
---
 test/zdtm/static/remap_dead_pid.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/test/zdtm/static/remap_dead_pid.c b/test/zdtm/static/remap_dead_pid.c
index 1ee61a9d0..261c591b7 100644
--- a/test/zdtm/static/remap_dead_pid.c
+++ b/test/zdtm/static/remap_dead_pid.c
@@ -35,12 +35,13 @@ int main(int argc, char **argv)
 	}
 
 	if (pid == 0) {
-		test_msg("child is %d\n", pid);
 		/* Child process just sleeps until it is killed. All we need
 		 * here is a process to open the mountinfo of. */
 		while(1)
 			sleep(10);
 	} else {
+		test_msg("child is %d\n", pid);
+
 		int fd, ret;
 		char path[PATH_MAX];
 		pid_t result;
-- 
2.13.3



More information about the CRIU mailing list