set default ping deadline in linux -


i want set default deadline ping in settings file or so. program hangs when trying connect non-pinging ip address.

in terminal can call "ping 123.0.0.1 -w 5" , wont last forever, can't set deadline in code.

shell solution:

in .bashrc add following:

function ping {     /bin/ping $@ -w5 } 

this create wrapper function, set timeout 5 seconds calls ping

note: version above overwrite -w param used on command line. if still want able overwrite default timeout via command line place -w5 before $@:

function ping {     /bin/ping -w5 $@ } 

pure c solution:

i won't give full example here brevity. may find 1 here example. in given example, you'll have replace recvfrom() call reads icmp response , may block select() or poll() call timeout.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -