diff options
author | Jase Thew <bazerka@irssi.org> | 2010-05-20 19:00:12 +0000 |
---|---|---|
committer | bazerka <bazerka@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2010-05-20 19:00:12 +0000 |
commit | cbe61df25c6d62d607d1d7e4c0a434633c2b9ed4 (patch) | |
tree | 1794b277bb33fef62755eefaaa65882419b3ee61 | |
parent | c6986ff767521911eb3821c25856eee975fb4178 (diff) | |
download | irssi-cbe61df25c6d62d607d1d7e4c0a434633c2b9ed4.zip |
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
-rw-r--r-- | src/fe-common/core/fe-exec.c | 17 |
1 files changed, 13 insertions, 4 deletions
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; } |