Questions tagged [process-groups]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
54
votes
5answers
38k views

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 ...
22
votes
1answer
19k views

What does kill 0 do actually? [closed]

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 ...
16
votes
1answer
25k views

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 (...
13
votes
1answer
17k views

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 ...
10
votes
1answer
918 views

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 ...
7
votes
5answers
18k views

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 ...
7
votes
1answer
2k views

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? ...
7
votes
1answer
9k views

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....
6
votes
3answers
479 views

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 ...
5
votes
2answers
1k views

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 <iostream> #include <ctime> #include <...
5
votes
1answer
269 views

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), ...
5
votes
1answer
635 views

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:...
4
votes
1answer
358 views

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 ...
4
votes
1answer
107 views

When process groups are usually created?

I have a program that spawns many instances of other programs. I want to have a clean way to kill them after timeout, even if they spawn subprocesses, sometimes accidentally daemonize, etc. Right now ...
4
votes
1answer
190 views

Start new process group in .xinitrc

I have a statusbar (lemonbar) to which I pipe the output of a couple of scripts (time, battery, volume, etc.). These scripts, and the statusbar itself, are all started in a single bash script ...
4
votes
1answer
90 views

Parent restarted by child doesn't respond to CTRL-C

I wrote a program. It starts a process (call it A) that spawns a child process (call it D) that shutdowns and restarts A. Problem is, now I can't kill A nicely from the terminal (ie. CTRL-C isn't ...
3
votes
3answers
701 views

Can Ctrl+C send the SIGINT signal to multiple processes?

I have read that when you press Ctrl+C a SIGINT signal will be sent to the foreground process group. Can you give me an example of how I can have two or more processes in the foreground process ...
3
votes
1answer
990 views

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.
3
votes
1answer
717 views

Kill job in subshell with set -m

I have the following bash script: #!/bin/bash set -m ( (bin/pnvd &> /dev/null; kill 0) & sleep 2 perl integration-test/fuzz-test.pl || kill 0 kill %1 ) The first three ...
2
votes
1answer
98 views

If the shell is running a program, will the shell also receive a SIGINT signal when Ctrl+C is pressed?

I have read that when you press Ctrl+C, then a SIGINT signal will be sent to the foreground process group. Now the accepted answer in this question says: Basically, your signal is received by all ...
2
votes
1answer
875 views

Cannot kill process group when invoked by PHP

I have a script spawning two zombies. I can kill the group via kill -- -<parent-pid>, but when invoked by the PHP interpreter, that won’t work although killing every single process manually will....
1
vote
1answer
50 views

Process Group Leader's PID reused

Is it possible that a past Progress Group Leader's PID gets reused by an other process and this latter process starts a new Process Group? In this case the first created process group and the second ...
1
vote
1answer
148 views

Must every process group belong to one process session?

Must every process group belong to one process session? In other words, is process group a concept which exists only within a process session? Is there a process group which doesn't belong to any ...
1
vote
1answer
115 views

Why can't a process change the process group ID of one of its children after that child has called one of the exec functions?

From APUE: A process can set the process group ID of only itself or any of its children. Furthermore, it can’t change the process group ID of one of its children after that child ...
1
vote
1answer
834 views

`sudo setsid command` does not spawn new process group?

I am looking at a scenario where I want to run a program / command with sudo as part of a software test. The commands are launched from a Python script based on the subprocess module. I am attempting ...
1
vote
1answer
231 views

setpgrp causes tty gone

When using setpgrp vi (and other tty programs) work completely different than if setpgrp is not used. Example: perl -MIPC::Open3 -e '$pid= open3("<&STDIN", ">&STDOUT", ">&STDERR",...
1
vote
0answers
232 views

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 ...
1
vote
0answers
26 views

Why are processes grouped by a PGID? [duplicate]

I am interested why processes are grouped additionally while having already a PPID and PID. What's the advantage of process groups?
1
vote
1answer
125 views

Why the process run by the shell does not inherit the shell's Process Group ID?

I have read that when Process A start Process B, then Process B will inherit Process A's Process Group ID. I tested this by making bash execute the cat program, but I found out that bash and cat had ...
1
vote
0answers
289 views

Work with setsid to open a session and close it correctly

I would like to create the following script: -- run a python script with setsid -- python may or may not fail with exception -- check if all of the group processes were terminated correctly -- if ...
1
vote
0answers
794 views

pkill -P $ID working while kill — -$ID not

I was playing around with creating and killing process groups on linux ( ubuntu ) I am trying to kill a process group and am being driven crazy by the fact that pkill -P $ID works while kill -- -$ID ...
0
votes
1answer
136 views

With multiple processes, can one process (p1) send a SIGALRM timing signal that is received by two or more processes (p1, p2).?

I think I now know the answer. Since the processes p2, p3, ...., are all children of the same parent p1, then all the processes are in the same process group so any signal (e.g. SIGALRM ??) set by p1 ...
0
votes
1answer
425 views

How can process become a member of a process group?

How can process become a member of a PGRP? My attempt: Process needs to be a child of a PGRP's leader or we need to use a system call setpgid(). Also, another two questions. 1) How can process ...
0
votes
0answers
19 views

Grouping processes in MINIX

I want to create a way of grouping user processes according to their PID - process belongs to group A when its PID is even (divisible by 2) and to group B otherwise. Basis on that I want to create a ...
0
votes
0answers
33 views

Can a process group exist without a process group leader

Saying that I have two bash scripts as below: #!/bin/bash # this is test.sh ./test2.sh and #!/bin/bash # this is test2.sh while : do sleep 2 done After executing the test.sh with the command ....
0
votes
1answer
174 views

Does kernel sending SIGHUP to a process group that becomes orphaned and contains a stopped process terminate all the processes by default?

In The Linux Programming Interface To see why orphaned process groups are important, we need to view things from the perspective of shell job control. Consider the following scenario based on ...
0
votes
2answers
410 views

Use waitpid for child having groupid 1

I searched a lot but didn't find a solution. So it can be silly question. The format of waitpid is pid_t waitpid (pid_t pid, int *status, int options) The pid parameter specifies exactly which ...