1 When minish is called without arguments, it reads from stdin.
2 This is interactive mode.
3 When it is called with an argument, it reads from the file thus named.
7 minish should not terminate when Ctrl+C is pressed
8 and a command is executing.
9 There are two ways of doing this:
11 or avoid being in the foreground process group so to not receive it.
12 Yesterday minish used the first way, but today I use the second.
14 When minish spawns a new process, with fork(),
15 this process puts itself in a new group just for itself
16 and declares this group as foreground.
17 When the child process terminates,
18 minish declare its own process group as foreground.
20 tcsetpgrp(fd, gpid) puts the gpid process group in the foreground
22 If gpid is in the background, it receives the signal SIGTTOU;
23 it means “stay put: you can do any output right now”
24 and its default action is to suspend, but it can be ignored.
26 1. create its own process group;
27 2. disable the handling of SIGTTOU;
28 3. puts its process group in the foreground;
29 4. re-enable the handling of SIGTTOU.
31 Using process groups paves the way to job control.
32 Without process groups, the shell could ignore SIGINT anyway,
33 but other background processes cannot:
34 if they did, we would be unable to stop them.
39 https://vidarholen.net/contents/blog/?p=34
40 https://gnu.org/software/bash/manual/html_node/Job-Control-Basics.html