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.
This commit is contained in:
Thiago de Arruda
2015-02-23 12:34:02 -03:00
parent 0b8d3cb507
commit 1ec7db70ec
9 changed files with 323 additions and 179 deletions

View File

@@ -132,14 +132,13 @@ uint64_t channel_from_job(char **argv)
incref(channel); // job channels are only closed by the exit_cb
int status;
channel->data.job = job_start(argv,
channel,
true,
job_out,
job_err,
job_exit,
0,
&status);
JobOptions opts = JOB_OPTIONS_INIT;
opts.argv = argv;
opts.data = channel;
opts.stdout_cb = job_out;
opts.stderr_cb = job_err;
opts.exit_cb = job_exit;
channel->data.job = job_start(opts, &status);
if (status <= 0) {
if (status == 0) { // Two decrefs needed if status == 0.