Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 04 Dec 2012 13:39:41 -0600
From:      Martin McCormick <martin@dc.cis.okstate.edu>
To:        freebsd-questions@freebsd.org
Subject:   Safe Way to Tell if Process is Running
Message-ID:  <201212041939.qB4JdfGt085863@x.it.okstate.edu>

next in thread | raw e-mail | index | archive | help
	About 20 years ago, I saw some code in which you
verified whether or not a process was running by giving it a
kill -0 command. If the process was running, nothing happened to
it but your kill -0 command exited with a 0 status. If there was
no process with that PID, the kill command exited non-zero.

	I use this in a system(command); in a C program I wrote
some years ago and I think this is now causing a segmentation
fault when the process number being signalled doesn't exist. Is
there a better way to determine if process number 12345 is
running without bothering it?

	None of the documentation on kill (1) shows a signal 0
nor does kill -l.

	Something tells me this is a bad idea these days, but I
still need an easy way to see if XYZ process is still alive.

	Thank you.

Martin McCormick WB5AGZ  Stillwater, OK 
Systems Engineer
OSU Information Technology Department Telecommunications Services Group



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212041939.qB4JdfGt085863>