about pppd termination?
Hi, All:
I think there are two reasons that cause pppd terminate himself: (1) the link has down (2) pppd has received SIGTERM
Whether these two kinds of termination process eventually go to a same path? or they finally call the same function. And the function is "die()" ? Thanks :)
Consider the ip_down_hook plugin hook if you want to catch either event.
pppd can also be killed with SIGKILL, unhandled, and so kernel destroys interface. No code in pppd executed. No ip_down_hook executed.
Signature · 3 lines
James Cameron http://quozl.netrek.org/ HP Open Source, Volunteer http://opensource.hp.com/ PPTP Client Project, Release Engineer http://pptpclient.sourceforge.net/
Thank you!
BTW,why the function "kill_my_pg(sig)" do a system call "kill(0,sig)" with the first parameter "0"? why not to kill himself only but a whole group?
2008-05-21cyx_mail
·¢¼şÈË£º James Cameron
·¢ËÍʱ¼ä£º 2008-05-21 14:55:44
ÊÕ¼şÈË£º cyx_mail
³ËÍ£º linux-ppp
Ö÷Ì⣺ Re: about pppd termination?
Consider the ip_down_hook plugin hook if you want to catch either event. pppd can also be killed with SIGKILL, unhandled, and so kernel destroys interface. No code in pppd executed. No ip_down_hook executed.
Signature · 10 lines
James Cameron http://quozl.netrek.org/ HP Open Source, Volunteer http://opensource.hp.com/ PPTP Client Project, Release Engineer http://pptpclient.sourceforge.net/ -- To unsubscribe from this list: send the line "unsubscribe linux-ppp" in the body of a message to [email protected] __________ NOD32 3090 (20080509) Information __________ This message was checked by NOD32 antivirus system. http://www.nod32cn.com ÿôèº{.nÇ+‰·Ÿ®‰†+%ŠËÿ±éݶ¥Šwÿº{.nÇ+‰·¥Š{±şšiş)í…æèw*jg¬±¨¶‰š�Šİ¢jÿ¾«şG«�éÿ¢¸¢·¦j:+v‰¨ŠwèjØm¶Ÿÿşø¯ù®w¥şŠàşf£¢·hš�â�úÿ†Ù¥
Quoted 1 line · cyx_mail
BTW,why the function "
kill_my_pg(sig)" do a system call "kill(0,sig)" with the first parameter "0"? why not to kill himself only but a whole group?
pppd acts as a process group leader, and sending a signal to the process group means that all children created by pppd (at least those that haven't gone off to start new process groups) will get the signal. This basically cleans up any charshunt or script that might be running in preparation to exit.
There'd be no point in pppd sending the signal to himself only. The whole reason that pppd is doing this at all is that it's about to exit! It has already gotten the signal; and talking to yourself is often not useful.
For more information about the kill(2) system call and process groups, see your system manual pages, or any reference book on UNIX or POSIX programming.
Signature · 1 line
James Carlson 42.703N 71.076W <[email protected]>
Quoted 5 lines · James Carlson
pppd acts as a process group leader, and sending a signal to the process group means that all children created by pppd (at least those that haven't gone off to start new process groups) will get the signal. This basically cleans up any charshunt or script that might be running in preparation to exit.
That reminds me. In the pptpconfig GUI we must define a handler for SIGINT before starting pppd, because if we don't the SIGINT we send to pppd comes back to us because of "kill(0,sig)". Why is this? popen is used to activate pppd, so that output from pppd is redirected to GUI.
Signature · 3 lines
James Cameron http://quozl.netrek.org/ HP Open Source, Volunteer http://opensource.hp.com/ PPTP Client Project, Release Engineer http://pptpclient.sourceforge.net/
Quoted 11 lines · James Cameron
Quoted 5 lines · James Carlson
pppd acts as a process group leader, and sending a signal to the process group means that all children created by pppd (at least those that haven't gone off to start new process groups) will get the signal. This basically cleans up any charshunt or script that might be running in preparation to exit.
That reminds me. In the pptpconfig GUI we must define a handler for SIGINT before starting pppd, because if we don't the SIGINT we send to pppd comes back to us because of "
kill(0,sig)". Why is this? popen is used to activate pppd, so that output from pppd is redirected to GUI.
I'm not familiar with that GUI. Is this a "nodetach" case? An alternative might be to avoid sending signals to the process group if pppd is not actually the group leader.
pppd ought to be in charge of its progeny, but parricide doesn't sound like the right answer. ;-}
Signature · 1 line
James Carlson 42.703N 71.076W <[email protected]>
Quoted 1 line · James Carlson
I'm not familiar with that GUI.
Good, I'm trying to let it die. It is written in PHP-GTK.
Quoted 1 line
Is this a "nodetach" case?
No, updetach is used.
Quoted 2 lines
An alternative might be to avoid sending signals to the process group if pppd is not actually the group leader.
This would have the side effect of not terminating the processes that pppd started. Wouldn't it be better if pppd made itself the group leader?
Signature · 3 lines
James Cameron http://quozl.netrek.org/ HP Open Source, Volunteer http://opensource.hp.com/ PPTP Client Project, Release Engineer http://pptpclient.sourceforge.net/
Quoted 7 lines · James Cameron
Quoted 2 lines · James Carlson
An alternative might be to avoid sending signals to the process group if pppd is not actually the group leader.
This would have the side effect of not terminating the processes that pppd started. Wouldn't it be better if pppd made itself the group leader?
Yes ... I was just trying to understand how you got into that state.
The detach() function (as long as you don't use nodetach) should get you into that process group leader status.
Is it possible that the signal was sent before the setsid() was done (i.e., before IPCP went Opened)? If so, then we might need to tweak how the process group is managed in the special case of (at least) updetach.
Signature · 1 line
James Carlson 42.703N 71.076W <[email protected]>
Quoted 4 lines · James Cameron
That reminds me. In the pptpconfig GUI we must define a handler for SIGINT before starting pppd, because if we don't the SIGINT we send to pppd comes back to us because of "
kill(0,sig)". Why is this? popen is used to activate pppd, so that output from pppd is redirected to GUI.
Because pppd does kill_my_pg when it gets a SIGTERM, SIGINT or SIGHUP even if it hasn't detached, and it probably shouldn't. Calling kill_my_pg is the right thing to do if pppd has detached, because then it has done a setsid. But if it hasn't detached, then any signal sent to the process group will get to any connector/disconnector processes that are running anyway. There does still remain the question of how pppd gets any connector/disconnector processes to stop if pppd has to terminate for other reasons, such as getting a SIGSEGV, though.
Paul.
Quoted 4 lines · James Carlson
Is it possible that the signal was sent before the
setsid()was done (i.e., before IPCP went Opened)? If so, then we might need to tweak how the process group is managed in the special case of (at least) updetach.
Yes, that's the situation. I remember now. Until we added the handler for SIGINT in the GUI, what would happen is that the GUI would die with a SIGINT as a result of the user hitting the "Cancel" button before the tunnel was established. That button sent a SIGINT to the pppd which had not yet detached.
Signature · 3 lines
James Cameron http://quozl.netrek.org/ HP Open Source, Volunteer http://opensource.hp.com/ PPTP Client Project, Release Engineer http://pptpclient.sourceforge.net/
Quoted 3 lines · Paul Mackerras
There does still remain the question of how pppd gets any connector/disconnector processes to stop if pppd has to terminate for other reasons, such as getting a SIGSEGV, though.
Yes, or SIGKILL. I remember one user who habitually used -9 and then complained that the connector (pptp) wasn't terminating forthwith.
Tracking each process created would be effective, and could remove the need for a process group kill. I'm just not sure if that level of change is justified.
Signature · 3 lines
James Cameron http://quozl.netrek.org/ HP Open Source, Volunteer http://opensource.hp.com/ PPTP Client Project, Release Engineer http://pptpclient.sourceforge.net/