mirror of
https://github.com/irssi/irssi.git
synced 2025-02-02 15:08:01 -05:00
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
This commit is contained in:
parent
c6986ff767
commit
cbe61df25c
@ -197,11 +197,16 @@ static void process_destroy(PROCESS_REC *rec, int status)
|
|||||||
static void processes_killall(int signum)
|
static void processes_killall(int signum)
|
||||||
{
|
{
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
|
int kill_ret;
|
||||||
|
|
||||||
for (tmp = processes; tmp != NULL; tmp = tmp->next) {
|
for (tmp = processes; tmp != NULL; tmp = tmp->next) {
|
||||||
PROCESS_REC *rec = tmp->data;
|
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;
|
PROCESS_REC *rec;
|
||||||
SERVER_REC *target_server;
|
SERVER_REC *target_server;
|
||||||
char *target, *level;
|
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
|
/* check that there's no unknown options. we allowed them
|
||||||
because signals can be used as options, but there should be
|
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) {
|
if (signum != -1) {
|
||||||
/* send a signal to process */
|
/* send a signal to process group */
|
||||||
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));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user