diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2017-07-25 11:59:08 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2017-11-25 09:37:00 +0100 |
commit | f629f8312d2a830ce7999a6612203977ec83daf8 (patch) | |
tree | 45a80adf76fb2e8a20857ea0300509fc7ba44237 /src/nvim/event/process.c | |
parent | 5517d2323ba359d5ed0cb9f0e9abdfc2a9871894 (diff) | |
download | rneovim-f629f8312d2a830ce7999a6612203977ec83daf8.tar.gz rneovim-f629f8312d2a830ce7999a6612203977ec83daf8.tar.bz2 rneovim-f629f8312d2a830ce7999a6612203977ec83daf8.zip |
channels: refactor jobwait
Diffstat (limited to 'src/nvim/event/process.c')
-rw-r--r-- | src/nvim/event/process.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c index 34be291aef..4eb2dd0baf 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/process.c @@ -145,16 +145,15 @@ void process_close_streams(Process *proc) FUNC_ATTR_NONNULL_ALL /// @param process Process instance /// @param ms Time in milliseconds to wait for the process. /// 0 for no wait. -1 to wait until the process quits. -/// @return Exit code of the process. +/// @return Exit code of the process. proc->status will have the same value. /// -1 if the timeout expired while the process is still running. /// -2 if the user interruped the wait. int process_wait(Process *proc, int ms, MultiQueue *events) FUNC_ATTR_NONNULL_ARG(1) { - int status = -1; // default bool interrupted = false; if (!proc->refcount) { - status = proc->status; + int status = proc->status; LOOP_PROCESS_EVENTS(proc->loop, proc->events, 0); return status; } @@ -190,7 +189,9 @@ int process_wait(Process *proc, int ms, MultiQueue *events) if (proc->refcount == 1) { // Job exited, collect status and manually invoke close_cb to free the job // resources - status = interrupted ? -2 : proc->status; + if (interrupted) { + proc->status = -2; + } decref(proc); if (events) { // the decref call created an exit event, process it now @@ -200,7 +201,7 @@ int process_wait(Process *proc, int ms, MultiQueue *events) proc->refcount--; } - return status; + return proc->status; } /// Ask a process to terminate and eventually kill if it doesn't respond |