<p>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.</p>

<p>What are my options to check</p>

<ul>
<li>if the link is available</li>
<li>if it routes to a server I control (it doesn't go to the internet as I said earlier)</li>
</ul>

<p>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 <code>system()</code> doesn't seem to give a PID, are there other options besides <code>fork()</code> and the gaggle of <code>exec??()</code> calls?</p>

<p>C on Linux on ARM (custom distribution using buildroot).</p>

[{'answer_id': 51313, 'author': 'T Percival', 'author_id': 954, 'author_profile': 'https://Stackoverflow.com/users/954', 'pm_score': 2, 'selected': False, 'text': '<p>You could parse <code>/proc/net/route</code>.</p>\n'}, {'answer_id': 160334, 'author': 'camh', 'author_id': 23744, 'author_profile': 'https://Stackoverflow.com/users/23744', 'pm_score': 4, 'selected': True, 'text': '<p>You can use the <code>ip-up</code> script functionality of pppd to have it execute a program when the IP interface is up and ready. Details are in the <a href="http://ppp.samba.org/pppd.html" rel="nofollow noreferrer">pppd(8) man page</a> - search for "ip-up".</p>\n\n<p>To restart pppd, use the <code>linkname</code> parameter to set a known pidfile name (<code>/var/run/ppp-name.pid</code>). Also use the <code>persist</code> option. When you want to restart pppd, send the <code>SIGHUP</code> signal. Again, this is described in the man page.</p>\n'}]
['https://Stackoverflow.com/questions/51296', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2915/']