Contents
When to create a new process group in Bash?
A typical situation where you’d want to create a session is if you were daemonizing a process, but other than that, there is usually not much use in creating a new session. You can run the script as a background job, as I mentioned, this will create a new process group.
What’s the difference between a job and a process?
The shell creates a process group within the current session for each “job” it launches, and places each process it starts into the appropriate process group. For example, ls | head is a pipeline of two processes, which the shell considers a single job, and will belong to a single, new process group.
What do you mean ” start a process in its own process group “?
What do you mean “start a process in its own process group”? The shell launches processes in their own process groups, that’s how it does job control (by having a process group for processes in the foreground, and several process groups for every pipeline launched on the background).
How does the shell control the process group?
Each shell you get at login becomes the leader of its own new session and process group, and sets the controlling process group of the terminal to itself. The shell creates a process group within the current session for each “job” it launches, and places each process it starts into the appropriate process group.
Why is the shell process the foreground process group?
Also, when a session has a controlling terminal, the shell process is usually the session leader, dictating which process group is the foreground process group (implicitly making the other groups background process groups). Processes in a group are usually put there by a linear pipeline.
How to create a process group in FreeBSD?
Using FreeBSD you may try using the script command that will internally execute the setsid command. This is not exactly answer, but is an alternative approach based on names. You can have a common part of name for all process. For example we have my_proc_group_29387172 part for all the following processes:
How is a signal sent to a process group?
A signal sent to a group is delivered to every process in that group. Using FreeBSD you may try using the script command that will internally execute the setsid command. This is not exactly answer, but is an alternative approach based on names.