[CRIU] [PATCH] zdtm/file_locks04: use test_waitsig() to synchronize child and parent

Andrey Vagin avagin at openvz.org
Tue Dec 22 20:51:02 PST 2015


From: Andrew Vagin <avagin at virtuozzo.com>

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 test/zdtm/live/static/file_locks04.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/test/zdtm/live/static/file_locks04.c b/test/zdtm/live/static/file_locks04.c
index 05e9bd2..995dd09 100644
--- a/test/zdtm/live/static/file_locks04.c
+++ b/test/zdtm/live/static/file_locks04.c
@@ -67,12 +67,10 @@ static int check_file_locks(int alt_pid, int fd)
 
 int main(int argc, char **argv)
 {
-	int fd, pf[2], pid;
+	int fd, pid;
 
 	test_init(argc, argv);
 
-	pipe(pf);
-
 	fd = open(filename, O_CREAT | O_RDWR, 0600);
 	if (fd < 0) {
 		pr_perror("No file");
@@ -83,25 +81,23 @@ int main(int argc, char **argv)
 
 	pid = fork();
 	if (pid == 0) {
-		close(pf[1]);
-		read(pf[0], &pid, sizeof(pid));
+		test_waitsig();
 		exit(0);
 	}
 
-	close(pf[0]);
 	close(fd);
 
 	fd = open(filename, O_RDONLY);
 	if (fd < 0) {
 		pr_perror("No file 2");
-		close(pf[1]);
+		kill(pid, SIGTERM);
 		waitpid(pid, NULL, 0);
 		return -1;
 	}
 
 	if (flock(fd, LOCK_EX | LOCK_NB) == 0) {
 		pr_perror("Bogus locks");
-		close(pf[1]);
+		kill(pid, SIGTERM);
 		waitpid(pid, NULL, 0);
 		return -1;
 	}
@@ -114,7 +110,7 @@ int main(int argc, char **argv)
 	else
 		fail("Flock file locks check failed");
 
-	close(pf[1]);
+	kill(pid, SIGTERM);
 	waitpid(pid, NULL, 0);
 	close(fd);
 	unlink(filename);
-- 
2.4.3



More information about the CRIU mailing list