Subject: pppd child process doesn't exit
To: , <tech-kern@netbsd.org>
From: Brad du Plessis <bradd@cat.co.za>
List: current-users
Date: 05/14/2004 11:57:07
Hi all,

I've got a little program that forks a child process which runs pppd 2.4.0.
The idea being that I can fork a pppd process to listen for an incoming call
on a modem and also dialout by killing this listening process and forking a
new pppd process to make the dialup. This gives me easy control over making
dialups automatically from various other processes running on the system by
sending the parent process UDP messages.

When I need to make a dialout, I use kill(my_child_pid, SIGTERM) to kill the
child process (which has pid my_child_pid) and the pppd code has a signal
handler installed which elegantly closes down pppd. At some stage I put an
_exit(0) at the end of the term(..) signal handler in the pppd code
(term(...) is the function pppd installs as the SIGTERM signal handler). Now
this works fine most of the time, the child will exit, I'll receive SIGCHLD
in the parent, it'll do a waitpid and I'll fork a new pppd process to do a
dialout. However, on occasion the SIGCHLD never arrives in the parent. I've
got a 30 second timer set after I run kill(...). When this times out, I just
call waitpid (in case I missed the SIGCHLD signal for some reason), waitpid
returns 0 (the child is still running) then I save a process listing for
debug purposes.

The process listing looks as follows:

10383 ??  IE    0:00.14 (mypppchild)
 3016 p1- S    19:15.93 ./conman

Process ID 3016 is the parent, ID 10383 is the child (pppd) after the parent
had sent SIGTERM 30 seconds before. It appears that for some reason the
child is trying to shutdown but has failed to do so even after 30 seconds.

Has anyone got any ideas as to what may cause this?

Thanks,
 Brad

PS I've seen this problem running NetBSD 1.5.1, 1.6.1 and 1.6.2