🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix
Article #273

Re: How to find process name in c

#273
From: Conor P. Cahill
Date: Wed, 17 Oct 1990 16:23
16 lines
1347 bytes
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 
Technical Details
Message-ID: <2213@megadon.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!altos!megadon!clp
References: <2190@megadon.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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