Does Linux Kernel always send signal to parent process












1















Hi just two questions about sending/receiveing signal



Q1- does Linux Kernel always send signals to parent process?



Q2- lets say I use fork() twice to create child processes



int main()
{
fork();
fork();
printf("hellon");
exit(0);
}


after the first fork(), a child process(lets say it is called child_1, and the parent process is called parent_1) is created.



On the second fork(), child_1 create another child process (lets say it is called child_2).



so my understanding is, child_1 is actually a parent process in the context of child_2, so now lets say the shell runs the program and a user type ctrl-c at the keyboard,
so the kernel sends the SIGINT, but to which process, parent_1 or child_1 or both, since child_1 is also parent process of child_2?










share|improve this question























  • Q1 is unclear. If you mean "when a process is signalled, does the kernel also always signal its parent", then the answer is No. If you mean something else, maybe you should explain.

    – Jonathan Leffler
    Nov 16 '18 at 1:44











  • After the first fork, you have a parent, P, and it has one child, C1. After the second fork, you have the parent P, and it has two children (C1, and C2), and C1 has a child process, G1. They all print and exit (why no newlines?). You might do better using pause() than exit(0); it gives you time to send a signal. If you type control-C at the keyboard exactly right (or you're using pause()), then the signal will be sent to all processes in a process group — and all of P, C1, C2, and G1 would be interrupted (receive the interrupt signal).

    – Jonathan Leffler
    Nov 16 '18 at 1:48








  • 1





    You might want to read this: stackoverflow.com/questions/6108953/…

    – mevets
    Nov 16 '18 at 2:03
















1















Hi just two questions about sending/receiveing signal



Q1- does Linux Kernel always send signals to parent process?



Q2- lets say I use fork() twice to create child processes



int main()
{
fork();
fork();
printf("hellon");
exit(0);
}


after the first fork(), a child process(lets say it is called child_1, and the parent process is called parent_1) is created.



On the second fork(), child_1 create another child process (lets say it is called child_2).



so my understanding is, child_1 is actually a parent process in the context of child_2, so now lets say the shell runs the program and a user type ctrl-c at the keyboard,
so the kernel sends the SIGINT, but to which process, parent_1 or child_1 or both, since child_1 is also parent process of child_2?










share|improve this question























  • Q1 is unclear. If you mean "when a process is signalled, does the kernel also always signal its parent", then the answer is No. If you mean something else, maybe you should explain.

    – Jonathan Leffler
    Nov 16 '18 at 1:44











  • After the first fork, you have a parent, P, and it has one child, C1. After the second fork, you have the parent P, and it has two children (C1, and C2), and C1 has a child process, G1. They all print and exit (why no newlines?). You might do better using pause() than exit(0); it gives you time to send a signal. If you type control-C at the keyboard exactly right (or you're using pause()), then the signal will be sent to all processes in a process group — and all of P, C1, C2, and G1 would be interrupted (receive the interrupt signal).

    – Jonathan Leffler
    Nov 16 '18 at 1:48








  • 1





    You might want to read this: stackoverflow.com/questions/6108953/…

    – mevets
    Nov 16 '18 at 2:03














1












1








1








Hi just two questions about sending/receiveing signal



Q1- does Linux Kernel always send signals to parent process?



Q2- lets say I use fork() twice to create child processes



int main()
{
fork();
fork();
printf("hellon");
exit(0);
}


after the first fork(), a child process(lets say it is called child_1, and the parent process is called parent_1) is created.



On the second fork(), child_1 create another child process (lets say it is called child_2).



so my understanding is, child_1 is actually a parent process in the context of child_2, so now lets say the shell runs the program and a user type ctrl-c at the keyboard,
so the kernel sends the SIGINT, but to which process, parent_1 or child_1 or both, since child_1 is also parent process of child_2?










share|improve this question














Hi just two questions about sending/receiveing signal



Q1- does Linux Kernel always send signals to parent process?



Q2- lets say I use fork() twice to create child processes



int main()
{
fork();
fork();
printf("hellon");
exit(0);
}


after the first fork(), a child process(lets say it is called child_1, and the parent process is called parent_1) is created.



On the second fork(), child_1 create another child process (lets say it is called child_2).



so my understanding is, child_1 is actually a parent process in the context of child_2, so now lets say the shell runs the program and a user type ctrl-c at the keyboard,
so the kernel sends the SIGINT, but to which process, parent_1 or child_1 or both, since child_1 is also parent process of child_2?







c linux exception signals






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 1:37









amjadamjad

50912




50912













  • Q1 is unclear. If you mean "when a process is signalled, does the kernel also always signal its parent", then the answer is No. If you mean something else, maybe you should explain.

    – Jonathan Leffler
    Nov 16 '18 at 1:44











  • After the first fork, you have a parent, P, and it has one child, C1. After the second fork, you have the parent P, and it has two children (C1, and C2), and C1 has a child process, G1. They all print and exit (why no newlines?). You might do better using pause() than exit(0); it gives you time to send a signal. If you type control-C at the keyboard exactly right (or you're using pause()), then the signal will be sent to all processes in a process group — and all of P, C1, C2, and G1 would be interrupted (receive the interrupt signal).

    – Jonathan Leffler
    Nov 16 '18 at 1:48








  • 1





    You might want to read this: stackoverflow.com/questions/6108953/…

    – mevets
    Nov 16 '18 at 2:03



















  • Q1 is unclear. If you mean "when a process is signalled, does the kernel also always signal its parent", then the answer is No. If you mean something else, maybe you should explain.

    – Jonathan Leffler
    Nov 16 '18 at 1:44











  • After the first fork, you have a parent, P, and it has one child, C1. After the second fork, you have the parent P, and it has two children (C1, and C2), and C1 has a child process, G1. They all print and exit (why no newlines?). You might do better using pause() than exit(0); it gives you time to send a signal. If you type control-C at the keyboard exactly right (or you're using pause()), then the signal will be sent to all processes in a process group — and all of P, C1, C2, and G1 would be interrupted (receive the interrupt signal).

    – Jonathan Leffler
    Nov 16 '18 at 1:48








  • 1





    You might want to read this: stackoverflow.com/questions/6108953/…

    – mevets
    Nov 16 '18 at 2:03

















Q1 is unclear. If you mean "when a process is signalled, does the kernel also always signal its parent", then the answer is No. If you mean something else, maybe you should explain.

– Jonathan Leffler
Nov 16 '18 at 1:44





Q1 is unclear. If you mean "when a process is signalled, does the kernel also always signal its parent", then the answer is No. If you mean something else, maybe you should explain.

– Jonathan Leffler
Nov 16 '18 at 1:44













After the first fork, you have a parent, P, and it has one child, C1. After the second fork, you have the parent P, and it has two children (C1, and C2), and C1 has a child process, G1. They all print and exit (why no newlines?). You might do better using pause() than exit(0); it gives you time to send a signal. If you type control-C at the keyboard exactly right (or you're using pause()), then the signal will be sent to all processes in a process group — and all of P, C1, C2, and G1 would be interrupted (receive the interrupt signal).

– Jonathan Leffler
Nov 16 '18 at 1:48







After the first fork, you have a parent, P, and it has one child, C1. After the second fork, you have the parent P, and it has two children (C1, and C2), and C1 has a child process, G1. They all print and exit (why no newlines?). You might do better using pause() than exit(0); it gives you time to send a signal. If you type control-C at the keyboard exactly right (or you're using pause()), then the signal will be sent to all processes in a process group — and all of P, C1, C2, and G1 would be interrupted (receive the interrupt signal).

– Jonathan Leffler
Nov 16 '18 at 1:48






1




1





You might want to read this: stackoverflow.com/questions/6108953/…

– mevets
Nov 16 '18 at 2:03





You might want to read this: stackoverflow.com/questions/6108953/…

– mevets
Nov 16 '18 at 2:03












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330242%2fdoes-linux-kernel-always-send-signal-to-parent-process%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330242%2fdoes-linux-kernel-always-send-signal-to-parent-process%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues