mirror of
https://github.com/irssi/irssi.git
synced 2025-02-02 15:08:01 -05:00
Added "exec new" and "exec remove" signals.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1110 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
8cb5ebc0a3
commit
3582973c93
@ -224,6 +224,10 @@ FE common
|
|||||||
fe-common-core.c:
|
fe-common-core.c:
|
||||||
"irssi init read settings"
|
"irssi init read settings"
|
||||||
|
|
||||||
|
fe-exec.c:
|
||||||
|
"exec new", int id, char *name, int pid, char *args
|
||||||
|
"exec remove", int id, char *name, int pid, int status
|
||||||
|
|
||||||
fe-messages.c:
|
fe-messages.c:
|
||||||
"message public", SERVER_REC, char *msg, char *nick, char *address, char *target
|
"message public", SERVER_REC, char *msg, char *nick, char *address, char *target
|
||||||
"message private", SERVER_REC, char *msg, char *nick, char *address
|
"message private", SERVER_REC, char *msg, char *nick, char *address
|
||||||
|
@ -140,10 +140,13 @@ static PROCESS_REC *process_find(const char *name, int verbose)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_destroy(PROCESS_REC *rec)
|
static void process_destroy(PROCESS_REC *rec, int status)
|
||||||
{
|
{
|
||||||
processes = g_slist_remove(processes, rec);
|
processes = g_slist_remove(processes, rec);
|
||||||
|
|
||||||
|
signal_emit("exec remove", 4, GINT_TO_POINTER(rec->id), rec->name,
|
||||||
|
GINT_TO_POINTER(rec->pid), GINT_TO_POINTER(status));
|
||||||
|
|
||||||
if (rec->read_tag != -1)
|
if (rec->read_tag != -1)
|
||||||
g_source_remove(rec->read_tag);
|
g_source_remove(rec->read_tag);
|
||||||
|
|
||||||
@ -400,7 +403,7 @@ static void handle_exec(const char *args, GHashTable *optlist,
|
|||||||
}
|
}
|
||||||
if (g_hash_table_lookup(optlist, "close") != NULL) {
|
if (g_hash_table_lookup(optlist, "close") != NULL) {
|
||||||
/* forcibly close the process */
|
/* forcibly close the process */
|
||||||
process_destroy(rec);
|
process_destroy(rec, -1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,8 +461,10 @@ static void handle_exec(const char *args, GHashTable *optlist,
|
|||||||
rec->read_tag = g_input_add(rec->in, G_INPUT_READ,
|
rec->read_tag = g_input_add(rec->in, G_INPUT_READ,
|
||||||
(GInputFunction) sig_exec_input_reader,
|
(GInputFunction) sig_exec_input_reader,
|
||||||
rec);
|
rec);
|
||||||
|
|
||||||
processes = g_slist_append(processes, rec);
|
processes = g_slist_append(processes, rec);
|
||||||
|
|
||||||
|
signal_emit("exec new", 4, GINT_TO_POINTER(rec->id), rec->name,
|
||||||
|
GINT_TO_POINTER(rec->pid), rec->args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: EXEC [-] [-nosh] [-out | -msg <target> | -notice <target>]
|
/* SYNTAX: EXEC [-] [-nosh] [-out | -msg <target> | -notice <target>]
|
||||||
@ -494,19 +499,19 @@ static void sig_pidwait(void *pid, void *statusp)
|
|||||||
/* process exited */
|
/* process exited */
|
||||||
if (!rec->silent) {
|
if (!rec->silent) {
|
||||||
if (WIFSIGNALED(status)) {
|
if (WIFSIGNALED(status)) {
|
||||||
|
status = WTERMSIG(status);
|
||||||
printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||||
"process %d (%s) terminated with signal %d (%s)",
|
"process %d (%s) terminated with signal %d (%s)",
|
||||||
rec->id, rec->args,
|
rec->id, rec->args,
|
||||||
WTERMSIG(status),
|
status, g_strsignal(status));
|
||||||
g_strsignal(WTERMSIG(status)));
|
|
||||||
} else {
|
} else {
|
||||||
|
status = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
|
||||||
printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||||
"process %d (%s) terminated with return code %d",
|
"process %d (%s) terminated with return code %d",
|
||||||
rec->id, rec->args,
|
rec->id, rec->args, status);
|
||||||
WIFEXITED(status) ? WEXITSTATUS(status) : -1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
process_destroy(rec);
|
process_destroy(rec, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sig_exec_input(PROCESS_REC *rec, const char *text)
|
static void sig_exec_input(PROCESS_REC *rec, const char *text)
|
||||||
@ -566,7 +571,7 @@ void fe_exec_deinit(void)
|
|||||||
processes_killall(SIGKILL);
|
processes_killall(SIGKILL);
|
||||||
|
|
||||||
while (processes != NULL)
|
while (processes != NULL)
|
||||||
process_destroy(processes->data);
|
process_destroy(processes->data, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
command_unbind("exec", (SIGNAL_FUNC) cmd_exec);
|
command_unbind("exec", (SIGNAL_FUNC) cmd_exec);
|
||||||
|
Loading…
Reference in New Issue
Block a user