Reputation: 11689
I have 2 programs (written by me). The first one called "MAN" will invoke "D" (the second one) which is a process that will run in background until terminated in some ways.
I would like to terminate MAN without terminating D.
I try to terminate MAN using ctrl + c and it terminates man correctly (I intercepted the sigint signal), now I want that D keeps running, however when MAN receives CTRL + C, D receive it too.
How to handle this situation? It's important that I would like to keep the possibility to run only D and terminate with CTRL + C. The problem comes when I run it through MAN, I don't want to terminate it with CTRL + C which should reach MAN only.
Any suggestion?
Upvotes: 0
Views: 245
Reputation: 16888
The child process (D) should disassociate from the controlling terminal by calling setsid(2)
.
Upvotes: 5