Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [process-groups]

The tag has no usage guidance.

1
vote
1answer
24 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
0answers
23 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?
5
votes
1answer
188 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), ...
0
votes
1answer
63 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 ...
3
votes
1answer
191 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.
0
votes
2answers
167 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 ...
1
vote
1answer
63 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
518 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 ...
6
votes
1answer
6k 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....
4
votes
1answer
329 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:...
0
votes
1answer
92 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 ...
2
votes
1answer
71 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 ...
1
vote
1answer
107 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 ...
3
votes
3answers
454 views

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

I have read that when you press Ctrl+C, then 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 ...
5
votes
2answers
785 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 <...
0
votes
1answer
369 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 ...
2
votes
1answer
635 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....
3
votes
1answer
525 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 ...
1
vote
1answer
106 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
0answers
258 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 ...
4
votes
1answer
83 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
155 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 ...
48
votes
5answers
29k 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 ...
1
vote
1answer
208 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",...
4
votes
1answer
87 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 ...
1
vote
0answers
616 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 ...
11
votes
1answer
14k 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 ...
16
votes
1answer
24k 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 (...
4
votes
1answer
288 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 ...
6
votes
5answers
16k 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 ...
18
votes
1answer
17k 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 ...
10
votes
1answer
808 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
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? ...