How to find process name in c
    Conor P. Cahill 
    cpcahil at virtech.UUCP
       
    Thu Oct 18 02:23:59 AEST 1990
    
    
  
In article <2190 at megadon.UUCP> lyns at 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 
    
    
More information about the Comp.unix
mailing list