1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 23:36:37 +02:00

core: fix detection of terminated process in hook_process

Check if the process is finished, even if stdout/stderr are not closed.
Moreover, if the process was terminated by a signal, the return code is
set to WEECHAT_HOOK_PROCESS_ERROR.
This commit is contained in:
Sebastien Helleu
2014-03-11 11:01:00 +01:00
parent acb24d9d2a
commit b6da2c3fa5
2 changed files with 12 additions and 3 deletions
+1
View File
@@ -15,6 +15,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
== Version 0.4.4 (under dev)
* core: fix detection of terminated process in hook_process
* core: set option weechat.look.buffer_search_where to prefix_message by default
* core: fix "/window scroll -N" on a buffer with free content
* core: add option weechat.look.hotlist_add_conditions, remove option
+11 -3
View File
@@ -1720,15 +1720,23 @@ hook_process_timer_cb (void *arg_hook_process, int remaining_calls)
}
else
{
if (!HOOK_PROCESS(hook_process, hook_fd[HOOK_PROCESS_STDOUT])
&& !HOOK_PROCESS(hook_process, hook_fd[HOOK_PROCESS_STDERR]))
if (waitpid (HOOK_PROCESS(hook_process, child_pid),
&status, WNOHANG) > 0)
{
if (waitpid (HOOK_PROCESS(hook_process, child_pid), &status, WNOHANG) > 0)
if (WIFEXITED(status))
{
/* child terminated normally */
rc = WEXITSTATUS(status);
hook_process_send_buffers (hook_process, rc);
unhook (hook_process);
}
else if (WIFSIGNALED(status))
{
/* child terminated by a signal */
hook_process_send_buffers (hook_process,
WEECHAT_HOOK_PROCESS_ERROR);
unhook (hook_process);
}
}
}