2011-06-15 11:27:11     PPP not closing tty file descriptor on exit ?

Document created by Aaronwu Employee on Aug 27, 2013
Version 1Show Document
  • View in full screen mode

2011-06-15 11:27:11     PPP not closing tty file descriptor on exit ?


Message: 101289   


I'm currently trying to manage a GPRS modem connection with pppd and some other scripts


At startup, I launch a script of my own (say script1), which does some work and finally establishes a connection with a GPRS modem ; this script then starts pppd and then it dies.


pppd configures the network interface (/dev/ppp0), lives as long as it may, until it dies (e.g. modem hangup). Just before it does, it starts a script in /etc/ppp, ip-down.


ip-down has been modified to launch again my own script, script1.


Now my problem: while pppd is running, if I go to /proc/<pppd pid>/fd I can see all the file descriptors opened by pppd.


At the first loop, some file descriptors are open, including one on /dev/ttyBF1 (say fd number 7).


At the second loop, the same file descriptors are open, including fd number 7 on /dev/ttyBF1, plus another fd (say fd number 10) also on /dev/ttyBF1


At every new loop, a new fd on /dev/ttyBF1 is opened, which makes the number of opened fd increase. Most probably, the system will end in a crash.


Is it a pppd bug (not closing the file descriptor before closing) ?


A problem with uClinux allowing some file descriptors to exist after the process who opened them died ?


(Probably the most important: ) is there a workaround ?






2011-06-15 11:34:00     Re: PPP not closing tty file descriptor on exit ?

Mike Frysinger (UNITED STATES)

Message: 101290   


all fd's of a process are closed by the kernel when it exits.  what you describe sounds more like the fd's are not being closed before execing children.


i imagine if you added O_CLOEXEC to all the relevant open() calls in pppd, this problem would fix itself.  or if in the child fork code, you close all the open fd's before doing the exec, that'd fix things too.