~emersion/mrsh

ref: df5641d1eb854fde1b5c537b1a52e69537ccf199 mrsh/shell/task/pipeline.c -rw-r--r-- 3.1 KiB
df5641d1 — Casey Duncan 10 months ago
Extra checks to ensure we don't clobber std fds
Move mrsh_state.child to mrsh_state_priv
Prefix structs in headers
Change fprintf(stderr, …, strerror(errno)) to perror
shell/task/pipeline: don't leak next stdin FD

Closes: https://github.com/emersion/mrsh/issues/95
shell/job: store AST node in job

Updates https://github.com/emersion/mrsh/issues/1
shell/task: create jobs with the pipeline/async list

Instead of creating jobs when executing their first process, create them when
creating the pipeline or async list.

This allows to track which pipeline created the job and will make possible to
attach the AST to the job in the future.

As of now, this breaks builtins such as fg(1) when called without an argument.
When executing fg(1) itself, a job is created and fg(1) picks this job instead
of the last one.
Remove pgid argument from job_create

Instead, decide the pgid when processes are added to the job (job_add_process).
This requires process structs to be created in the children too.

Future plans: create the jobs before spawning the child processes, so that we
can attach the AST to jobs.
shell/task/pipeline: fix assertion
shell: fix pipeline bangs
shell: fix pipelines
shell/task: add pipeline bang
shell/task: add pipelines
shell/task: remove

This will get replaced with much simpler code.
Improve docs
Only create jobs if job control is enabled
Add context.background
Maintain a list of running jobs
Put commands into process groups

This is the first step towards job control support.
Remove context.{stdin,stdout}_fileno

These we too fragile, nesting wasn't properly supported.

Instead, we now use dup() to setup and restore stdin and stdout in pipelines.
Next