diff options
Diffstat (limited to 'mbinputmgr.c')
-rw-r--r-- | mbinputmgr.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/mbinputmgr.c b/mbinputmgr.c index 12a84ea..be98469 100644 --- a/mbinputmgr.c +++ b/mbinputmgr.c @@ -1,5 +1,21 @@ #include "mbinputmgr.h" +void +cleanup_children(int s) +{ + kill(-getpid(), 15); /* kill every one in our process group */ + exit(0); +} + +void +install_signal_handlers(void) +{ + signal (SIGCHLD, SIG_IGN); /* kernel can deal with zombies */ + signal (SIGINT, cleanup_children); + signal (SIGQUIT, cleanup_children); + signal (SIGTERM, cleanup_children); +} + static void fork_exec(MBInpmgrState *inpmgr, char *cmd) { @@ -98,6 +114,8 @@ mbinpmgr_init(void) char orig_wd[256]; int i; + install_signal_handlers(); + inpmgr = malloc(sizeof(MBInpmgrState)); memset(inpmgr,0,sizeof(MBInpmgrState)); |