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.
api: add option "signal" in function hook_set to send a signal to the child process