Relative Content

Tag Archive for c++linuxforksudochild-process

Using sudo, why are detached child process terminated when the parent dies?

I’m writing a program that requires admin privileges (an updater). At some point, we need to start another program and let the first one end. So the parent process makes a fork, detaches from its child and ends execution.
As root (using “su” for exemple), everything works as expected.
As a regular user, nothing special happens (except of course for writing files as root).
But, using sudo, as soon as the parent process ends its execution, its child dies as well.

Using sudo, why do detached child process “crash” when the parent dies?

I’m writing a program that requires admin privileges (an updater). At some point, we need to start another program and let the first one end. So the parent process makes a fork, detaches from its child and ends execution.
As root (using “su” for exemple), everything works as expected.
As a regular user, nothing special happens (except of course for writing files as root).
But, using sudo, as soon as the parent process ends its execution, its child dies as well.