Commit a21ea70d authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

zdtm/file_locks04: use test_waitsig() to synchronize child and parent

Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent bd806a78
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment