mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 05:18:00 +00:00
zdtm/file_locks04: use test_waitsig() to synchronize child and parent
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
bd806a7832
commit
a21ea70df2
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user