always create a new process group
PATCH 2/14 always create a new process group
pppd sends signals to the whole process group, so it must always create a new one or it may kill the parent process and its siblings. Currently setsid() is not called when the updetach option is used. We want to make the detached and non-detached code paths as similar as possible.
http://ppp.samba.org/cgi-bin/ppp-bugs/incoming?id11
http://ppp.samba.org/cgi-bin/ppp-bugs/incoming?id89
pppd/main.c +7 -2
@@ -433,6 +433,13 @@ main(argc, argv) }/* +* pppd sends signals to the whole process group, so it must always +* create a new one or it may kill the parent process and its siblings. +*/ +setsid (); +chdir ("/" ); + +/* * Initialize system-dependent stuff. */ sys_init ();
@@ -775,8 +782,6 @@ detach()create_linkpidfile (pid);exit (0 );/* parent dies */ } -setsid (); -chdir ("/" );dup2 (fd_devnull,0 );dup2 (fd_devnull,1 );dup2 (fd_devnull,2 );
Signature · 2 lines
ciao, Marco
Quoted 5 lines · Marco d'Itri
pppd sends signals to the whole process group, so it must always create a new one or it may kill the parent process and its siblings. Currently
setsid()is not called when the updetach option is used. We want to make the detached and non-detached code paths as similar as possible.
I know there is a problem here but I don't think this patch is the right solution, because setsid fails and does nothing if the process is a process group leader, which it usually will be when run from a shell. There is a reason why the setsid in detach() is only done after forking.
Paul.
Quoted 8 lines · Paul Mackerras
Quoted 5 lines · Marco d'Itri
pppd sends signals to the whole process group, so it must always create a new one or it may kill the parent process and its siblings. Currently
setsid()is not called when the updetach option is used. We want to make the detached and non-detached code paths as similar as possible.
Quoted 4 lines
I know there is a problem here but I don't think this patch is the right solution, because setsid fails and does nothing if the process is a process group leader, which it usually will be when run from a shell.
The return value from setsid is not checked, so I don't see the problem here. After the call, the pppd process is the leader of a process group (whether it was before or not), which is what we want.
Quoted 2 lines
There is a reason why the setsid in
detach()is only done after forking.
To be clear, what is that reason?
Quoted 3 lines · Charlie Brady
The return value from setsid is not checked, so I don't see the problem here. After the call, the pppd process is the leader of a process group (whether it was before or not), which is what we want.
That's true, but it also means that pppd won't get the SIGINT if the user types ^C, which is not what we want either.
Quoted 4 lines
Quoted 2 lines
There is a reason why the setsid in
detach()is only done after forking.To be clear, what is that reason?
The child process won't be a process group leader, therefore the setsid will succeed.
Paul.