Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!lll-winken!tekbspa!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: comp.unix.questions Subject: Re: How to find process name in c? Message-ID: <1990Jul15.015957.22028@virtech.uucp> Date: 15 Jul 90 01:59:57 GMT References: <200001@carter.BCASDL.BOEING.COM> Reply-To: cpcahil@virtech.UUCP (Conor P. Cahill) Organization: Virtual Technologies Inc., Sterling VA Lines: 19 In article <200001@carter.BCASDL.BOEING.COM> lyn@carter.BCASDL.BOEING.COM ( Lyn Stewart ) 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. An easy way to see if a particular executable is running is to try to open the file with write permissions. If you get the errno ETXTBSY, the executable is being run. If you don't know the full pathname to the executable, or if you need additional information (other than the fact that the program is running, like who is running it or how much cpu it is using, etc) you need to run ps and parse the output (or replicate the ps code in your program). -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc., uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170