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

@@ -201,14 +201,14 @@ static int shell(const char *cmd,
char **argv = shell_build_argv(cmd, extra_args);
int status;
Job *job = job_start(argv,
&buf,
input != NULL,
data_cb,
data_cb,
NULL,
0,
&status);
JobOptions opts = JOB_OPTIONS_INIT;
opts.argv = argv;
opts.data = &buf;
opts.writable = input != NULL;
opts.stdout_cb = data_cb;
opts.stderr_cb = data_cb;
opts.exit_cb = NULL;
Job *job = job_start(opts, &status);
if (status <= 0) {
// Failed, probably due to `sh` not being executable