mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-01 14:55:39 +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:
committed by
Pavel Emelyanov
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 main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int fd, pf[2], pid;
|
int fd, pid;
|
||||||
|
|
||||||
test_init(argc, argv);
|
test_init(argc, argv);
|
||||||
|
|
||||||
pipe(pf);
|
|
||||||
|
|
||||||
fd = open(filename, O_CREAT | O_RDWR, 0600);
|
fd = open(filename, O_CREAT | O_RDWR, 0600);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
pr_perror("No file");
|
pr_perror("No file");
|
||||||
@@ -83,25 +81,23 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
close(pf[1]);
|
test_waitsig();
|
||||||
read(pf[0], &pid, sizeof(pid));
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
close(pf[0]);
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
fd = open(filename, O_RDONLY);
|
fd = open(filename, O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
pr_perror("No file 2");
|
pr_perror("No file 2");
|
||||||
close(pf[1]);
|
kill(pid, SIGTERM);
|
||||||
waitpid(pid, NULL, 0);
|
waitpid(pid, NULL, 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flock(fd, LOCK_EX | LOCK_NB) == 0) {
|
if (flock(fd, LOCK_EX | LOCK_NB) == 0) {
|
||||||
pr_perror("Bogus locks");
|
pr_perror("Bogus locks");
|
||||||
close(pf[1]);
|
kill(pid, SIGTERM);
|
||||||
waitpid(pid, NULL, 0);
|
waitpid(pid, NULL, 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -114,7 +110,7 @@ int main(int argc, char **argv)
|
|||||||
else
|
else
|
||||||
fail("Flock file locks check failed");
|
fail("Flock file locks check failed");
|
||||||
|
|
||||||
close(pf[1]);
|
kill(pid, SIGTERM);
|
||||||
waitpid(pid, NULL, 0);
|
waitpid(pid, NULL, 0);
|
||||||
close(fd);
|
close(fd);
|
||||||
unlink(filename);
|
unlink(filename);
|
||||||
|
Reference in New Issue
Block a user