From cbe61df25c6d62d607d1d7e4c0a434633c2b9ed4 Mon Sep 17 00:00:00 2001 From: Jase Thew Date: Thu, 20 May 2010 19:00:12 +0000 Subject: When sending a signal to an /exec'd command, send it to the process group id instead of the process id. (This covers the case of /bin/sh instances which fork/exec commands passed via -c. In such cases, sending a signal to the stored process id would sent it to the /bin/sh process itself, not the forked child.) Add error reporting to sending signals. git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@5174 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-common/core/fe-exec.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/fe-common/core') diff --git a/src/fe-common/core/fe-exec.c b/src/fe-common/core/fe-exec.c index 894d2673..0faabb3c 100644 --- a/src/fe-common/core/fe-exec.c +++ b/src/fe-common/core/fe-exec.c @@ -197,11 +197,16 @@ static void process_destroy(PROCESS_REC *rec, int status) static void processes_killall(int signum) { GSList *tmp; + int kill_ret; for (tmp = processes; tmp != NULL; tmp = tmp->next) { PROCESS_REC *rec = tmp->data; - kill(rec->pid, signum); + kill_ret = kill(-rec->pid, signum); + if (kill_ret != 0) + printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, + "Error sending signal %d to pid %d: %s", + signum, rec->pid, g_strerror(errno)); } } @@ -378,7 +383,7 @@ static void handle_exec(const char *args, GHashTable *optlist, PROCESS_REC *rec; SERVER_REC *target_server; char *target, *level; - int notice, signum, interactive, target_nick, target_channel; + int notice, signum, interactive, target_nick, target_channel, kill_ret; /* check that there's no unknown options. we allowed them because signals can be used as options, but there should be @@ -445,8 +450,12 @@ static void handle_exec(const char *args, GHashTable *optlist, } if (signum != -1) { - /* send a signal to process */ - kill(rec->pid, signum); + /* send a signal to process group */ + kill_ret = kill(-rec->pid, signum); + if (kill_ret != 0) + printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, + "Error sending signal %d to pid %d: %s", + signum, rec->pid, g_strerror(errno)); return; } -- cgit v1.2.3