Commit a5dff04d authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

socket_listen: interrupt a parent if a child exited

When a child exited, SIGCHLD is sent to parent,
if SIGCHLD has handler without SA_RESTART, the current
syscall will be interrupted.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent c6066105
...@@ -28,6 +28,8 @@ int init_server(); ...@@ -28,6 +28,8 @@ int init_server();
#define BUF_SIZE 1024 #define BUF_SIZE 1024
static void sig_hand(int signo) {}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
unsigned char buf[BUF_SIZE]; unsigned char buf[BUF_SIZE];
...@@ -36,6 +38,10 @@ int main(int argc, char **argv) ...@@ -36,6 +38,10 @@ int main(int argc, char **argv)
pid_t pid; pid_t pid;
int res; int res;
uint32_t crc; uint32_t crc;
struct sigaction sa = {
.sa_handler = sig_hand,
/* don't set SA_RESTART */
};
test_init(argc, argv); test_init(argc, argv);
...@@ -47,6 +53,10 @@ int main(int argc, char **argv) ...@@ -47,6 +53,10 @@ int main(int argc, char **argv)
test_daemon(); test_daemon();
test_waitsig(); test_waitsig();
sigemptyset(&sa.sa_mask);
if (sigaction(SIGCHLD, &sa, NULL))
fprintf(stderr, "Can't set SIGTERM handler: %m\n");
pid = test_fork(); pid = test_fork();
if (pid < 0) { if (pid < 0) {
err("fork failed. Return %d %m", pid); err("fork failed. Return %d %m", pid);
......
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