[talk] kill -0

Edward Capriolo edlinuxguru at gmail.com
Fri May 10 15:31:45 EDT 2019


On Fri, May 10, 2019 at 3:06 PM Pete Wright <pete at nomadlogic.org> wrote:

>
>
> On 2019-05-10 11:59, Pete Wright wrote:
> >
> >
> > On 2019-05-10 11:00, Raul Cuza wrote:
> >> Hola People Who Use Shells,
> >>
> >> I just had someone submit a shell script using `kill -0 ${PID}` to
> >> test if a process is running. It exits non-zero if ${PID} isn't a
> >> running process and zero otherwise. But...
> >>
> >> http://nixdoc.net/man-pages/FreeBSD/kill.1.html says nothing about it.
> >>
> >> The ubuntu man page mentions it poorly with "Particularly useful
> >> signals include HUP, INT, KILL, STOP, CONT, and 0." Looking at `kill
> >> --list` there is no signal 0.
> >>
> >> And stackoverflow says
> >>
> https://stackoverflow.com/questions/11012527/what-does-kill-0-pid-in-a-shell-script-do
> >>
> >> matching what the person who submitted the PR says.
> >>
> >> Am I wrong to think this should be accomplished in a way with better
> >> documentation? I feel like I am nit picking.
> >
> > this seems like a bash'ism - from the bash manpage:
> >
> > SIGNALS
> >        When bash is interactive, in the absence of any traps, it ignores
> >        SIGTERM (so that kill 0 does not kill an interactive shell),
> > and SIGINT
> >        is caught and handled (so that the wait builtin is
> > interruptible).  In
> >        all cases, bash ignores SIGQUIT.  If job control is in effect,
> > bash
> >        ignores SIGTTIN, SIGTTOU, and SIGTSTP.
> >
> >
>
> heh wish i saw Jan's post before i wrote this as his reply seems to
> answer the real question...
>
> -p
>
> --
> Pete Wright
> pete at nomadlogic.org
> @nomadlogicLA
>
> _______________________________________________
> talk mailing list
> talk at lists.nycbug.org
> http://lists.nycbug.org:8080/mailman/listinfo/talk
>


It feels safer to me to use ps route.  Even if you are counting the os to
preserve the 0 behaviour I feel I would fat finger it and send a kill -1 or
2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.nycbug.org:8443/pipermail/talk/attachments/20190510/a0c93f47/attachment.htm>


More information about the talk mailing list