Commit 835e252b authored by Andrei Vagin's avatar Andrei Vagin

test/ptrace_sig: wait children before calling test_daemon

A static test has to do nothing after test_daemon().
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent a31c1854
......@@ -59,8 +59,8 @@ int main(int argc, char ** argv)
{
int ret, status = 0;
pid_t pid, spid, cpid;
int signal_pipe[2];
int child_pipe[2];
siginfo_t siginfo;
test_init(argc, argv);
......@@ -81,9 +81,10 @@ int main(int argc, char ** argv)
}
close(child_pipe[1]);
ret = pipe(signal_pipe);
if (ret < 0) {
pr_perror("pipe failed");
test_msg("wait while child initialized");
ret = read(child_pipe[0], &status, sizeof(status));
if (ret != sizeof(status)) {
pr_perror("read from child process failed");
return 1;
}
......@@ -92,12 +93,6 @@ int main(int argc, char ** argv)
pr_perror("Can't fork signal process");
return 1;
} else if (spid == 0) {
close(signal_pipe[1]);
ret = read(signal_pipe[0], &status, sizeof(status));
if (ret != sizeof(status)) {
pr_perror("read");
return 1;
}
test_msg("send signal to %d\n", cpid);
ret = kill(cpid, SIGUSR2);
if (ret < 0) {
......@@ -105,20 +100,15 @@ int main(int argc, char ** argv)
}
return 0;
}
close(signal_pipe[0]);
test_msg("wait while child initialized");
ret = read(child_pipe[0], &status, sizeof(status));
if (ret != sizeof(status)) {
pr_perror("read from child process failed");
if (waitid(P_PID, spid, &siginfo, WEXITED | WNOWAIT)) {
pr_perror("Unable to wait spid");
return 1;
}
ret = write(signal_pipe[1], &status, sizeof(status));
if (ret != sizeof(status)) {
pr_perror("write to signal process failed");
if (waitid(P_PID, cpid, &siginfo, WSTOPPED | WNOWAIT)) {
pr_perror("Unable to wait cpid");
return 1;
}
close(signal_pipe[1]);
test_daemon();
test_waitsig();
......@@ -133,7 +123,6 @@ int main(int argc, char ** argv)
}
if (WIFSTOPPED(status)) {
siginfo_t siginfo;
test_msg("pid=%d stopsig=%d\n", pid, WSTOPSIG(status));
......
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