Questions tagged [process-groups]

38 questions
86
votes
5 answers

Run multiple commands and kill them as one in bash

I want to run multiple commands (processes) on a single shell. All of them have own continuous output and don't stop. Running them in the background breaks Ctrl-C. I would like to run them as a single process (subshell, maybe?) to be able to stop…
27
votes
1 answer

What does kill 0 do actually?

In the man page, it says: kill [ -s signal | -p ] [ -a ] [ -- ] pid ... pid... Specify the list of processes that kill should signal. Each pid can be one of five things: 0 All processes in the current process group are signaled And…
Firegun
  • 1,829
  • 3
  • 15
  • 9
20
votes
1 answer

Is it possible to get process group ID from /proc?

In "https://stackoverflow.com/questions/13038143/how-to-get-pids-in-one-process-group-in-linux-os" I see all answers mentioning ps and none mentioning /proc. "ps" seems to be not very portable (Android and Busybox versions expect different…
Vi.
  • 5,528
  • 7
  • 34
  • 68
17
votes
1 answer

How is a process group ID set?

I have read that a session's ID is the same as the pid of the process that created the session through the setsid() system call, but I haven't found any information about how a process group ID is set. Is the process group ID the same as the pid of…
user7681202
  • 1,273
  • 2
  • 14
  • 25
14
votes
1 answer

Why is the PGID of my child processes not the PID of the parent?

So I keep reading everywhere that this command should terminate all child processes of the parent process: kill -- -$$ Using a negative ID with the kill command references a PGID and from the examples I have seen it appears the PGID of child…
TCZ8
  • 1,069
  • 4
  • 14
  • 24
11
votes
1 answer

Difference between process group and job?

What's the difference between a process group and a job? If I type pr * | lpr then is it both a process group as well a job? What exactly is the difference between a process group ID and a job ID? Edit: I know it appears similar to What is the…
Naruto Uzumaki
  • 213
  • 2
  • 4
10
votes
1 answer

What should interactive shells do in orphaned process groups?

(Re-posting in unix per the suggestion in https://stackoverflow.com/questions/13718394/what-should-interactive-shells-do-in-orphaned-process-groups) The short question is, what should a shell do if it is in an orphaned process group that doesn't own…
ridiculous_fish
  • 1,661
  • 10
  • 15
8
votes
3 answers

Does a process’s parent have any significance from the perspective of its child?

In POSIX, processes are “related” to each other through two basic hierarchies: The hierarchy of parent and child processes. The hierarchy of sessions and process groups. User processes have a great deal of control over the latter, via setpgid and…
Alexis King
  • 555
  • 1
  • 4
  • 15
7
votes
5 answers

kill a group of processes with negative PID

kill -TERM -PID is supposed to kill PID and all its child processes. but this doesn't work on openSUSE, it always tell me that no such process -PID no matter what PID i use. So if the negative PID option is not supported by this particular version…
SparedWhisle
  • 3,588
  • 4
  • 22
  • 35
7
votes
2 answers

how can I start a bash script in its own process group

I would like to start a bash script from another bash script, but start it in its own process group just like when you run it from the terminal. There are a few similar questions, but I can't find an answer that matches my example. Take these two…
Alex028502
  • 469
  • 7
  • 12
6
votes
1 answer

Why do we need to send SIGHUP to a newly orphaned process group containing a stopped process?

The Advanced Programming in the UNIX Environment book ("APUE") says Consider a process that forks a child and then terminates. Although this is nothing abnormal (it happens all the time), what happens if the child is stopped (using …
Tim
  • 98,580
  • 191
  • 570
  • 977
6
votes
1 answer

Is there a way to change the process group of a running process?

Is there a way to change PID, PPID, SID of a running process? It would make sense for the answer to be no, but I'd like to make sure.
extremeaxe5
  • 1,133
  • 9
  • 19
5
votes
1 answer

How to move a process from one process group to another, and how to list the processes in each process group?

Based on what I have learned so far, a terminal has only one session, and a session has one or more process groups, and a process group has one or more processes. The following image illustrates this: I have two questions: How to move a process…
user259392
  • 83
  • 1
  • 5
5
votes
2 answers

Why is process not part of expected process group?

I'm learning about the relationship between processes, process groups (and sessions) in Linux. I compiled the following program... #include #include #include int main( int argc, char* argv[] ) { char buf[128]; …
StoneThrow
  • 1,575
  • 5
  • 19
  • 41
4
votes
1 answer

What is the purpose of abstractions, session, session leader and process groups?

I understand from Informit article that sessions and process groups are used to terminate descendant processes on exit and send signals to related processes with job control. I believe this information can be extracted at any point using the PPID of…
rag
  • 1,246
  • 2
  • 19
  • 31
1
2 3