So I’m running PPP under linux with a cellular modem. The program I’m writing needs to know if the link is active before sending any data.
What are my options to check
- if the link is available
- if it routes to a server I control (it doesn’t go to the internet as I said earlier)
Also, what is the best way to restart it – I’d like to have program control over when it starts and stops, so I assume an init.d isn’t appropriate. Using system() doesn’t seem to give a PID, are there other options besides fork() and the gaggle of exec??() calls?
C on Linux on ARM (custom distribution using buildroot).
You can use the
ip-upscript functionality of pppd to have it execute a program when the IP interface is up and ready. Details are in the pppd(8) man page – search for ‘ip-up’.To restart pppd, use the
linknameparameter to set a known pidfile name (/var/run/ppp-name.pid). Also use thepersistoption. When you want to restart pppd, send theSIGHUPsignal. Again, this is described in the man page.