Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!altos!megadon!clp From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.unix Subject: Re: How to find process name in c Message-ID: <2213@megadon.UUCP> Date: 17 Oct 90 16:23:59 GMT References: <2190@megadon.UUCP> Sender: clp@megadon.UUCP Reply-To: uunet!virtech!cpcahil (Conor P. Cahill) Organization: Virtual Technologies Inc., Sterling VA Lines: 16 Approved: clp@megadon.UUCP In article <2190@megadon.UUCP> lyns@atc.boeing.com writes: >Has anyone got a method for finding out if a process is running short of >"ps -ef | grep processname" in a pipe. There must be a better way from >within a c program. If you are trying to find out if a particular executable is running (as opposed to finding out if any programs named "xyz" are running) you can just try to open the file for writing. If the open fails with ETXTBSY, the executable is being run. Note that this works even if you don't have write permission on the file because the text-busy condition is usually checked before the access permissions. -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc., uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170