diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2014-03-11 11:01:00 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2014-03-11 11:01:00 +0100 |
commit | b6da2c3fa5b62d73d6e8262498d81952d5a71874 (patch) | |
tree | fce98554f5d6d25440b035f5b82283ce95d2f4a7 | |
parent | acb24d9d2a4b0b4aeb74cf347c35d7c803aef324 (diff) | |
download | weechat-b6da2c3fa5b62d73d6e8262498d81952d5a71874.zip |
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.
-rw-r--r-- | ChangeLog.asciidoc | 1 | ||||
-rw-r--r-- | src/core/wee-hook.c | 14 |
2 files changed, 12 insertions, 3 deletions
diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index a5469b81a..8819c5b9a 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -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 diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index 04c2affef..bbc6b055b 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -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); + } } } |