diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-06-17 10:02:09 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-06-18 11:36:07 -0300 |
commit | 71d9899f3cbcb2c3fc290925e5fd4300f2b9cf8c (patch) | |
tree | e62935fe1c17261d124156c03c421f1e972c1936 /src/nvim/os/channel.c | |
parent | 05fd154ede5d88b7304ede9cea978d6b76d1fb44 (diff) | |
download | rneovim-71d9899f3cbcb2c3fc290925e5fd4300f2b9cf8c.tar.gz rneovim-71d9899f3cbcb2c3fc290925e5fd4300f2b9cf8c.tar.bz2 rneovim-71d9899f3cbcb2c3fc290925e5fd4300f2b9cf8c.zip |
job: Refactor to use pointers instead of ids
'job_start' returns the id as an out paramter, and the 'job_find' function is
now used by eval.c to translate job ids into pointers.
Diffstat (limited to 'src/nvim/os/channel.c')
-rw-r--r-- | src/nvim/os/channel.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/nvim/os/channel.c b/src/nvim/os/channel.c index 878aeac0a8..fd5eae505c 100644 --- a/src/nvim/os/channel.c +++ b/src/nvim/os/channel.c @@ -24,7 +24,7 @@ typedef struct { msgpack_unpacker *unpacker; msgpack_sbuffer *sbuffer; union { - int job_id; + Job *job; struct { RStream *read; WStream *write; @@ -68,11 +68,25 @@ void channel_teardown() /// stdin/stdout. stderr is forwarded to the editor error stream. /// /// @param argv The argument vector for the process -void channel_from_job(char **argv) +bool channel_from_job(char **argv) { Channel *channel = register_channel(); channel->is_job = true; - channel->data.job_id = job_start(argv, channel, job_out, job_err, NULL); + + int status; + channel->data.job = job_start(argv, + channel, + job_out, + job_err, + NULL, + &status); + + if (status <= 0) { + close_channel(channel); + return false; + } + + return true; } /// Creates an API channel from a libuv stream representing a tcp or @@ -282,7 +296,9 @@ static void close_channel(Channel *channel) msgpack_unpacker_free(channel->unpacker); if (channel->is_job) { - job_stop(channel->data.job_id); + if (channel->data.job) { + job_stop(channel->data.job); + } } else { rstream_free(channel->data.streams.read); wstream_free(channel->data.streams.write); |