aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/job_defs.h
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2015-02-23 12:34:02 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2015-02-23 21:43:33 -0300
commit1ec7db70ecac75736b5042203e57aae57b65abe6 (patch)
treed2f169ac3a5c7460d04997e31efd104920e68c5e /src/nvim/os/job_defs.h
parent0b8d3cb5074031d04ad3def786775853e67ecfbe (diff)
downloadrneovim-1ec7db70ecac75736b5042203e57aae57b65abe6.tar.gz
rneovim-1ec7db70ecac75736b5042203e57aae57b65abe6.tar.bz2
rneovim-1ec7db70ecac75736b5042203e57aae57b65abe6.zip
job: Refactor process spawning and startup arguments
- process spawning was decoupled from the rest of the job control logic. The goal is reusing it for spawning processes connected to pseudo terminal file descriptors. - job_start now receives a JobOptions structure containing all the startup options.
Diffstat (limited to 'src/nvim/os/job_defs.h')
-rw-r--r--src/nvim/os/job_defs.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/nvim/os/job_defs.h b/src/nvim/os/job_defs.h
index a9caa169a8..340ef551be 100644
--- a/src/nvim/os/job_defs.h
+++ b/src/nvim/os/job_defs.h
@@ -1,7 +1,9 @@
#ifndef NVIM_OS_JOB_DEFS_H
#define NVIM_OS_JOB_DEFS_H
+#include <uv.h>
#include "nvim/os/rstream_defs.h"
+#include "nvim/os/wstream_defs.h"
typedef struct job Job;
@@ -11,4 +13,39 @@ typedef struct job Job;
/// @param data Some data associated with the job by the caller
typedef void (*job_exit_cb)(Job *job, void *data);
+// Job startup options
+// job_exit_cb Callback that will be invoked when the job exits
+// maxmem Maximum amount of memory used by the job WStream
+typedef struct {
+ // Argument vector for the process. The first item is the
+ // executable to run.
+ // [consumed]
+ char **argv;
+ // Caller data that will be associated with the job
+ void *data;
+ // If true the job stdin will be available for writing with job_write,
+ // otherwise it will be redirected to /dev/null
+ bool writable;
+ // Callback that will be invoked when data is available on stdout. If NULL
+ // stdout will be redirected to /dev/null.
+ rstream_cb stdout_cb;
+ // Callback that will be invoked when data is available on stderr. If NULL
+ // stderr will be redirected to /dev/null.
+ rstream_cb stderr_cb;
+ // Callback that will be invoked when the job has exited and will not send
+ // data
+ job_exit_cb exit_cb;
+ // Maximum memory used by the job's WStream
+ size_t maxmem;
+} JobOptions;
+
+#define JOB_OPTIONS_INIT ((JobOptions) { \
+ .argv = NULL, \
+ .data = NULL, \
+ .writable = true, \
+ .stdout_cb = NULL, \
+ .stderr_cb = NULL, \
+ .exit_cb = NULL, \
+ .maxmem = 0 \
+ })
#endif // NVIM_OS_JOB_DEFS_H