keeping an occasional ping alive
Craig White
CraigWhite@AzApple.com
Thu, 6 Jul 2000 23:53:40 -0700
ya gotta love this board...just a simple thing like keeping a stupid ping
alive got two terrific ideas from Kevin & Jean.
I am so humbled...
----:----|----:----|----:----|----:----|----:----|----:----|
- Craig White - PO Box 8634 - Scottsdale, Arizona - 85252
- e-mail address ................ - CraigWhite@AzApple.com
- world wide web address ........ - http://www.AzApple.com
- e-mail my pager address ....... - 6023779752@airtouch.net
- cellular phone ................ - (602) 377-9752
- voice/facsimile ............... - (480) 945-8445
----:----|----:----|----:----|----:----|----:----|----:----|
> -----Original Message-----
> From: plug-discuss-admin@lists.plug.phoenix.az.us
> [mailto:plug-discuss-admin@lists.plug.phoenix.az.us]On Behalf Of Kevin
> Buettner
> Sent: Thursday, July 06, 2000 10:00 PM
> To: plug-discuss@lists.plug.phoenix.az.us
> Subject: Re: keeping an occasional ping alive
>
>
> On Jul 6, 8:30pm, Craig White wrote:
>
> > I have a client that has a problem with their ISDN and we want
> to keep the
> > connection alive - so we would probably want to ping an internet address
> > once every 30 seconds.
> >
> > I read man ping and found that I can ping address -i30 -q but I
> want that
> > process in the background so I get a shell prompt so I add an
> ampersand to
> > the line to make it...
> >
> > ping (address) -i30 -q &
> >
> > but it still doesn't return to the shell prompt unless I hit
> return a second
> > time - why? can anyone clue in the clueless? Is this a
> reasonable way to do
> > this?
>
> Are you certain that you're not seeing a shell prompt?
>
> E.g, when I try it, here's what I see:
>
> ocotillo:kev$ ping 192.168.2.1 -i30 -q &
> [1] 3192
> ocotillo:kev$ PING 192.168.2.1 (192.168.2.1) from 192.168.2.7
> : 56(84) bytes of data.
>
>
> Note that the prompt and the initial output from ping ended up on
> the same line. You can avoid even the initial output by doing the
> following:
>
> ocotillo:kev$ ping 192.168.2.1 -i30 -q >/dev/null &
> [1] 3209
> ocotillo:kev$
>
> The parent of the ping will be your shell process. It may be
> desirable to "daemonize" the ping process so that your shell
> can exit without killing the ping. You can do that as follows:
>
> ocotillo:kev$ ( ping 192.168.2.1 -i30 -q >/dev/null & ) &
> [1] 3222
> ocotillo:kev$
> [1]+ Done ( ping 192.168.2.1 -i30 -q
> >/dev/null & )
>
> The ping hasn't really exited, only the subshell enclosed by parens has
> exited. If you grep for ping, it's still alive and kicking:
>
> ocotillo:kev$ ps axlww | grep ping
> 100 204 3223 1 4 0 1224 472 skb_re S pts/28
> 0:00 ping 192.168.2.1 -i30 -q
>
> Note that the ping's parent pid is 1 which is the init process. This is
> normal for child processes who've lost their parent; init inherits them.
> This is good because 1) it allows you to exit your shell without killing
> the ping and 2) if the ping should exit for some reason, init will do
> the wait() or waitpid() and prevent the process from becoming a zombie.
> (Actually, the shell should do this for you too, but it possible to
> come up with a pathological example in which a zombie is created.)
>
> Kevin
>
> _______________________________________________
> Plug-discuss mailing list - Plug-discuss@lists.PLUG.phoenix.az.us
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss