summaryrefslogtreecommitdiffstats
path: root/logwrapper/logwrap.c
diff options
context:
space:
mode:
Diffstat (limited to 'logwrapper/logwrap.c')
-rw-r--r--logwrapper/logwrap.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/logwrapper/logwrap.c b/logwrapper/logwrap.c
index ef457de..99a462f 100644
--- a/logwrapper/logwrap.c
+++ b/logwrapper/logwrap.c
@@ -176,13 +176,15 @@ void sigchld_handler(int sig) {
write(signal_fd_write, &sig, 1);
}
-int logwrap(int argc, char* argv[], int *status) {
+int logwrap(int argc, char* argv[], int *status, bool ignore_int_quit) {
pid_t pid;
int parent_ptty;
int child_ptty;
char *child_devname = NULL;
struct sigaction chldact;
struct sigaction oldchldact;
+ struct sigaction intact;
+ struct sigaction quitact;
sigset_t blockset;
sigset_t oldset;
int sockets[2];
@@ -204,6 +206,8 @@ int logwrap(int argc, char* argv[], int *status) {
}
sigemptyset(&blockset);
+ sigaddset(&blockset, SIGINT);
+ sigaddset(&blockset, SIGQUIT);
sigaddset(&blockset, SIGCHLD);
sigprocmask(SIG_BLOCK, &blockset, &oldset);
@@ -231,6 +235,8 @@ int logwrap(int argc, char* argv[], int *status) {
fatal("This should never happen\n");
return -1;
} else {
+ struct sigaction ignact;
+
memset(&chldact, 0, sizeof(chldact));
chldact.sa_handler = sigchld_handler;
chldact.sa_flags = SA_NOCLDSTOP;
@@ -245,6 +251,13 @@ int logwrap(int argc, char* argv[], int *status) {
"handler and might cause interaction issues");
}
+ if (ignore_int_quit) {
+ memset(&ignact, 0, sizeof(ignact));
+ ignact.sa_handler = SIG_IGN;
+ sigaction(SIGINT, &ignact, &intact);
+ sigaction(SIGQUIT, &ignact, &quitact);
+ }
+
rc = socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
if (rc == -1) {
char msg[40];
@@ -268,6 +281,10 @@ int logwrap(int argc, char* argv[], int *status) {
close(sockets[0]);
close(sockets[1]);
err_socketpair:
+ if (ignore_int_quit) {
+ sigaction(SIGINT, &intact, NULL);
+ sigaction(SIGQUIT, &quitact, NULL);
+ }
sigaction(SIGCHLD, &oldchldact, NULL);
err_fork:
sigprocmask(SIG_SETMASK, &oldset, NULL);