diff options
Diffstat (limited to 'srcx')
-rw-r--r-- | srcx/jkill.c | 4 | ||||
-rw-r--r-- | srcx/util.c | 17 | ||||
-rw-r--r-- | srcx/util.h | 3 |
3 files changed, 21 insertions, 3 deletions
diff --git a/srcx/jkill.c b/srcx/jkill.c index aa7f9b8..faf86ea 100644 --- a/srcx/jkill.c +++ b/srcx/jkill.c @@ -113,9 +113,7 @@ int main(int argc, char* argv[]) err(1, "couldn't disconnect from console"); /* Ignore these signals as all sorts of crazy stuff happens around our process */ - signal(SIGHUP, SIG_IGN); - signal(SIGPIPE, SIG_IGN); - signal(SIGTERM, SIG_IGN); + ignore_signals (); r = kill_jail(argv[0]); exit(r); diff --git a/srcx/util.c b/srcx/util.c index 8542b35..6aad984 100644 --- a/srcx/util.c +++ b/srcx/util.c @@ -379,6 +379,7 @@ int run_simple_command(const char* jail, const char* cmd, char* env[], /* This is the child here */ case 0: + unignore_signals (); if(args) execve(cmd, args, env); else @@ -446,6 +447,8 @@ int run_dup_command(const char* jail, const char* cmd, char* env[], /* This is the child here */ case 0: { + unignore_signals (); + /* Fix up our end of the pipe */ if(dup2(outpipe[WRITE_END], STDOUT) < 0 || dup2(outpipe[WRITE_END], STDERR) < 0) @@ -579,3 +582,17 @@ int run_jail_command(const char* jail, const char* cmd, char* args[], int opts) return run_simple_command(jail, cmd, env, args, opts); } +void ignore_signals(void) +{ + signal(SIGHUP, SIG_IGN); + signal(SIGPIPE, SIG_IGN); + signal(SIGTERM, SIG_IGN); +} + +void unignore_signals(void) +{ + signal(SIGHUP, SIG_DFL); + signal(SIGPIPE, SIG_DFL); + signal(SIGTERM, SIG_DFL); +} + diff --git a/srcx/util.h b/srcx/util.h index cc359b1..91f2b49 100644 --- a/srcx/util.h +++ b/srcx/util.h @@ -65,5 +65,8 @@ void jails_done(jails *jls); int run_jail_command(const char* jail, const char* cmd, char* args[], int opts); int check_jail_command(const char* jail, const char* cmd); +void ignore_signals(void); +void unignore_signals(void); + #endif /* __UTIL_H__ */ |