nixpulvis / oursh

Your comrade through the perilous world of UNIX.
http://nixpulvis.com/oursh/oursh
MIT License
67 stars 6 forks source link

Background Jobs #6

Open nixpulvis opened 6 years ago

nixpulvis commented 6 years ago

We need to support the basic fg, bg, and jobs, wait commands, background syntax &, and the signal SIGTSTP typically invoked via ctrl-z.

The disown command is standard in Bash, but I'm not sure how I feel about it yet.

The main design work here is going to be around the needed event loop / threading to properly track and manage background jobs while the main shell is running. I suppose a single threaded solution exists, but I doubt it's a good idea.

nixpulvis commented 6 years ago

Started in b78ae21e8a059ec5e7d355cdda91292264ec824c

nixpulvis commented 6 years ago

The syntax seems to all be correctly parsing now, and I'm pretty sure I'm happy about background jobs owning a Command and not a Program.

nixpulvis commented 6 years ago

https://en.wikipedia.org/wiki/Job_control_(Unix)

nixpulvis commented 6 years ago

Going to try and sort this out on job-exec-ohmy.

nixpulvis commented 5 years ago

https://blog.nelhage.com/2010/01/a-brief-introduction-to-termios-signaling-and-job-control/

nixpulvis commented 5 years ago

https://tokio.rs/blog/2018-08-async-await/

nixpulvis commented 5 years ago

https://github.com/nixpulvis/lambash/commit/6fd53def4b7ec9d57cc2811468cf9eb5a0729169

nixpulvis commented 3 years ago

The implementation at the moment seems to work quite well (at least in the basic cases I hand tested), however I'm aware of some shortcuts I've taken. For example, background compound statements, e.g. Background(Compound(vec![A, B])) should run A then B as a process group together in a single background job.

For example try:

{ echo 1; sleep 2; echo 2; }

I would guess that the solution to this will be related to the solution to #58.