What happens to a unix session when the session leader exits?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I'm trying to properly emulate POSIX signals handling and job control for my pet operating system, but it's not clear to me what should happen to a session after the session leader exits.
I cannot find documentation related to what happens to the session and its process if, for example, a child kills the session leader while several background processes and a different foreground process are running.
My tests show that all the process in the session are killed, but how?
Do they receive a specific signal?
Is this case specified in the POSIX standard? And if so, can you provide some references?
posix process-management
add a comment |Â
up vote
1
down vote
favorite
I'm trying to properly emulate POSIX signals handling and job control for my pet operating system, but it's not clear to me what should happen to a session after the session leader exits.
I cannot find documentation related to what happens to the session and its process if, for example, a child kills the session leader while several background processes and a different foreground process are running.
My tests show that all the process in the session are killed, but how?
Do they receive a specific signal?
Is this case specified in the POSIX standard? And if so, can you provide some references?
posix process-management
Some related questions are unix.stackexchange.com/questions/405755 , unix.stackexchange.com/questions/84737 , unix.stackexchange.com/questions/18166 , and unix.stackexchange.com/questions/282973 .
â JdeBP
Nov 28 '17 at 10:16
@JdeBP interesting links, but it's still hard to say what is expected to happen if the session leader exits. Even considered that the session leader might not be a shell.
â Giacomo Tesio
Nov 28 '17 at 10:52
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm trying to properly emulate POSIX signals handling and job control for my pet operating system, but it's not clear to me what should happen to a session after the session leader exits.
I cannot find documentation related to what happens to the session and its process if, for example, a child kills the session leader while several background processes and a different foreground process are running.
My tests show that all the process in the session are killed, but how?
Do they receive a specific signal?
Is this case specified in the POSIX standard? And if so, can you provide some references?
posix process-management
I'm trying to properly emulate POSIX signals handling and job control for my pet operating system, but it's not clear to me what should happen to a session after the session leader exits.
I cannot find documentation related to what happens to the session and its process if, for example, a child kills the session leader while several background processes and a different foreground process are running.
My tests show that all the process in the session are killed, but how?
Do they receive a specific signal?
Is this case specified in the POSIX standard? And if so, can you provide some references?
posix process-management
asked Nov 28 '17 at 9:35
Giacomo Tesio
4551615
4551615
Some related questions are unix.stackexchange.com/questions/405755 , unix.stackexchange.com/questions/84737 , unix.stackexchange.com/questions/18166 , and unix.stackexchange.com/questions/282973 .
â JdeBP
Nov 28 '17 at 10:16
@JdeBP interesting links, but it's still hard to say what is expected to happen if the session leader exits. Even considered that the session leader might not be a shell.
â Giacomo Tesio
Nov 28 '17 at 10:52
add a comment |Â
Some related questions are unix.stackexchange.com/questions/405755 , unix.stackexchange.com/questions/84737 , unix.stackexchange.com/questions/18166 , and unix.stackexchange.com/questions/282973 .
â JdeBP
Nov 28 '17 at 10:16
@JdeBP interesting links, but it's still hard to say what is expected to happen if the session leader exits. Even considered that the session leader might not be a shell.
â Giacomo Tesio
Nov 28 '17 at 10:52
Some related questions are unix.stackexchange.com/questions/405755 , unix.stackexchange.com/questions/84737 , unix.stackexchange.com/questions/18166 , and unix.stackexchange.com/questions/282973 .
â JdeBP
Nov 28 '17 at 10:16
Some related questions are unix.stackexchange.com/questions/405755 , unix.stackexchange.com/questions/84737 , unix.stackexchange.com/questions/18166 , and unix.stackexchange.com/questions/282973 .
â JdeBP
Nov 28 '17 at 10:16
@JdeBP interesting links, but it's still hard to say what is expected to happen if the session leader exits. Even considered that the session leader might not be a shell.
â Giacomo Tesio
Nov 28 '17 at 10:52
@JdeBP interesting links, but it's still hard to say what is expected to happen if the session leader exits. Even considered that the session leader might not be a shell.
â Giacomo Tesio
Nov 28 '17 at 10:52
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
You are not the only one puzzled by POSIX sessions; Lennart Poettering (he of systemd
fame) is puzzled too.
As far as anybody can tell, when a session leader dies, init
inherits the orphaned session and
All session member processes in the foreground process group (if any) receive a SIGHUP.
Session member processes who are not in the foreground group don't receive any signal.
See also:
- notes.shichao.io/apue/ch9
- Chapter 10 "Processes" in The Linux Kernel by Andries Brouwer (2003).
If the terminal goes away by modem hangup, and the line was not local, then a SIGHUP is sent to the session leader. [...] When the session leader dies, a SIGHUP is sent to all processes in the foreground process group. [...] Thus, if the terminal goes away and the session leader is a job control shell, then it can handle things for its descendants, e.g. by sending them again a SIGHUP. If on the other hand the session leader is an innocent process that does not catch SIGHUP, it will die, and all foreground processes get a SIGHUP.
Andries Brower, The Linux Kernel, section 10.3 "Sessions".
As for "All session member processes in the foreground process group (if any) receive a SIGHUP.": do you know who send the SIGHUP? In unix.stackexchange.com/questions/84737/⦠it seems that bash send the signal... and this would invalidate part of your answer.
â Giacomo Tesio
Nov 28 '17 at 14:37
@GiacomoTesio: See added quotation from The Linux Kernel.
â AlexP
Nov 28 '17 at 16:09
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
You are not the only one puzzled by POSIX sessions; Lennart Poettering (he of systemd
fame) is puzzled too.
As far as anybody can tell, when a session leader dies, init
inherits the orphaned session and
All session member processes in the foreground process group (if any) receive a SIGHUP.
Session member processes who are not in the foreground group don't receive any signal.
See also:
- notes.shichao.io/apue/ch9
- Chapter 10 "Processes" in The Linux Kernel by Andries Brouwer (2003).
If the terminal goes away by modem hangup, and the line was not local, then a SIGHUP is sent to the session leader. [...] When the session leader dies, a SIGHUP is sent to all processes in the foreground process group. [...] Thus, if the terminal goes away and the session leader is a job control shell, then it can handle things for its descendants, e.g. by sending them again a SIGHUP. If on the other hand the session leader is an innocent process that does not catch SIGHUP, it will die, and all foreground processes get a SIGHUP.
Andries Brower, The Linux Kernel, section 10.3 "Sessions".
As for "All session member processes in the foreground process group (if any) receive a SIGHUP.": do you know who send the SIGHUP? In unix.stackexchange.com/questions/84737/⦠it seems that bash send the signal... and this would invalidate part of your answer.
â Giacomo Tesio
Nov 28 '17 at 14:37
@GiacomoTesio: See added quotation from The Linux Kernel.
â AlexP
Nov 28 '17 at 16:09
add a comment |Â
up vote
3
down vote
accepted
You are not the only one puzzled by POSIX sessions; Lennart Poettering (he of systemd
fame) is puzzled too.
As far as anybody can tell, when a session leader dies, init
inherits the orphaned session and
All session member processes in the foreground process group (if any) receive a SIGHUP.
Session member processes who are not in the foreground group don't receive any signal.
See also:
- notes.shichao.io/apue/ch9
- Chapter 10 "Processes" in The Linux Kernel by Andries Brouwer (2003).
If the terminal goes away by modem hangup, and the line was not local, then a SIGHUP is sent to the session leader. [...] When the session leader dies, a SIGHUP is sent to all processes in the foreground process group. [...] Thus, if the terminal goes away and the session leader is a job control shell, then it can handle things for its descendants, e.g. by sending them again a SIGHUP. If on the other hand the session leader is an innocent process that does not catch SIGHUP, it will die, and all foreground processes get a SIGHUP.
Andries Brower, The Linux Kernel, section 10.3 "Sessions".
As for "All session member processes in the foreground process group (if any) receive a SIGHUP.": do you know who send the SIGHUP? In unix.stackexchange.com/questions/84737/⦠it seems that bash send the signal... and this would invalidate part of your answer.
â Giacomo Tesio
Nov 28 '17 at 14:37
@GiacomoTesio: See added quotation from The Linux Kernel.
â AlexP
Nov 28 '17 at 16:09
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
You are not the only one puzzled by POSIX sessions; Lennart Poettering (he of systemd
fame) is puzzled too.
As far as anybody can tell, when a session leader dies, init
inherits the orphaned session and
All session member processes in the foreground process group (if any) receive a SIGHUP.
Session member processes who are not in the foreground group don't receive any signal.
See also:
- notes.shichao.io/apue/ch9
- Chapter 10 "Processes" in The Linux Kernel by Andries Brouwer (2003).
If the terminal goes away by modem hangup, and the line was not local, then a SIGHUP is sent to the session leader. [...] When the session leader dies, a SIGHUP is sent to all processes in the foreground process group. [...] Thus, if the terminal goes away and the session leader is a job control shell, then it can handle things for its descendants, e.g. by sending them again a SIGHUP. If on the other hand the session leader is an innocent process that does not catch SIGHUP, it will die, and all foreground processes get a SIGHUP.
Andries Brower, The Linux Kernel, section 10.3 "Sessions".
You are not the only one puzzled by POSIX sessions; Lennart Poettering (he of systemd
fame) is puzzled too.
As far as anybody can tell, when a session leader dies, init
inherits the orphaned session and
All session member processes in the foreground process group (if any) receive a SIGHUP.
Session member processes who are not in the foreground group don't receive any signal.
See also:
- notes.shichao.io/apue/ch9
- Chapter 10 "Processes" in The Linux Kernel by Andries Brouwer (2003).
If the terminal goes away by modem hangup, and the line was not local, then a SIGHUP is sent to the session leader. [...] When the session leader dies, a SIGHUP is sent to all processes in the foreground process group. [...] Thus, if the terminal goes away and the session leader is a job control shell, then it can handle things for its descendants, e.g. by sending them again a SIGHUP. If on the other hand the session leader is an innocent process that does not catch SIGHUP, it will die, and all foreground processes get a SIGHUP.
Andries Brower, The Linux Kernel, section 10.3 "Sessions".
edited Nov 28 '17 at 16:12
answered Nov 28 '17 at 11:28
AlexP
6,656924
6,656924
As for "All session member processes in the foreground process group (if any) receive a SIGHUP.": do you know who send the SIGHUP? In unix.stackexchange.com/questions/84737/⦠it seems that bash send the signal... and this would invalidate part of your answer.
â Giacomo Tesio
Nov 28 '17 at 14:37
@GiacomoTesio: See added quotation from The Linux Kernel.
â AlexP
Nov 28 '17 at 16:09
add a comment |Â
As for "All session member processes in the foreground process group (if any) receive a SIGHUP.": do you know who send the SIGHUP? In unix.stackexchange.com/questions/84737/⦠it seems that bash send the signal... and this would invalidate part of your answer.
â Giacomo Tesio
Nov 28 '17 at 14:37
@GiacomoTesio: See added quotation from The Linux Kernel.
â AlexP
Nov 28 '17 at 16:09
As for "All session member processes in the foreground process group (if any) receive a SIGHUP.": do you know who send the SIGHUP? In unix.stackexchange.com/questions/84737/⦠it seems that bash send the signal... and this would invalidate part of your answer.
â Giacomo Tesio
Nov 28 '17 at 14:37
As for "All session member processes in the foreground process group (if any) receive a SIGHUP.": do you know who send the SIGHUP? In unix.stackexchange.com/questions/84737/⦠it seems that bash send the signal... and this would invalidate part of your answer.
â Giacomo Tesio
Nov 28 '17 at 14:37
@GiacomoTesio: See added quotation from The Linux Kernel.
â AlexP
Nov 28 '17 at 16:09
@GiacomoTesio: See added quotation from The Linux Kernel.
â AlexP
Nov 28 '17 at 16:09
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f407448%2fwhat-happens-to-a-unix-session-when-the-session-leader-exits%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Some related questions are unix.stackexchange.com/questions/405755 , unix.stackexchange.com/questions/84737 , unix.stackexchange.com/questions/18166 , and unix.stackexchange.com/questions/282973 .
â JdeBP
Nov 28 '17 at 10:16
@JdeBP interesting links, but it's still hard to say what is expected to happen if the session leader exits. Even considered that the session leader might not be a shell.
â Giacomo Tesio
Nov 28 '17 at 10:52