aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlns <matzeton@googlemail.com>2018-04-27 00:32:51 +0200
committerlns <matzeton@googlemail.com>2018-04-27 00:32:51 +0200
commit2c18582245f9b68369a4bb25e602dd449ccf6410 (patch)
treee23dcc953085f7a74e164df5bbc57c76177418ff
parent9a00263a93836a1ad36491298df49d151d09554d (diff)
POTD sekelton #33.
Signed-off-by: lns <matzeton@googlemail.com>
-rw-r--r--src/jail.c4
-rw-r--r--src/server.c4
-rw-r--r--src/utils.c4
3 files changed, 8 insertions, 4 deletions
diff --git a/src/jail.c b/src/jail.c
index 04bfd21..abf88e5 100644
--- a/src/jail.c
+++ b/src/jail.c
@@ -161,10 +161,8 @@ static int jail_mainloop_epoll(int epoll_fd, jail_ctx *ctx[], size_t siz)
assert(ctx);
assert(siz > 0 && siz < POTD_MAXFD);
- set_procname("[potd] jaild");
+ set_procname("[potd] jail");
assert( set_child_sighandler() == 0 );
- assert( signal(SIGCHLD, SIG_IGN) != SIG_ERR );
- assert( signal(SIGPIPE, SIG_IGN) != SIG_ERR );
sigemptyset(&eset);
D2("Epoll fd: %d", epoll_fd);
diff --git a/src/server.c b/src/server.c
index 6627afa..afa2172 100644
--- a/src/server.c
+++ b/src/server.c
@@ -9,6 +9,7 @@
#include "server.h"
#include "socket.h"
+#include "utils.h"
#include "log.h"
typedef struct client_thread_args {
@@ -160,7 +161,8 @@ static int server_mainloop_epoll(int epoll_fd, server_ctx *ctx[], size_t siz)
assert(ctx);
assert(siz > 0 && siz < POTD_MAXFD);
- assert( signal(SIGPIPE, SIG_IGN) != SIG_ERR );
+ set_procname("[potd] server");
+ assert( set_child_sighandler() == 0 );
sigemptyset(&eset);
while (1) {
diff --git a/src/utils.c b/src/utils.c
index ada3c13..3b44331 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -38,6 +38,9 @@ int set_child_sighandler(void)
{
if (prctl(PR_SET_PDEATHSIG, SIGHUP) != 0)
return 1;
+ assert( signal(SIGCHLD, SIG_IGN) != SIG_ERR );
+ assert( signal(SIGPIPE, SIG_IGN) != SIG_ERR );
+
return signal(SIGHUP, sighandler_child) == SIG_ERR;
}
@@ -101,6 +104,7 @@ pid_t daemonize(int stay_foreground)
chdir("/");
/* Close all open file descriptors */
assert( close_fds_except(-1) == 0 );
+ assert( redirect_devnull_to(0, 1, 2, -1) == 0 );
} else {
assert( close_fds_except(0, 1, 2, -1) == 0 );
}