Detecting if Linux Program Running 
Author Message
 Detecting if Linux Program Running

Is there any easy way using python under Linux to detect whether a
particular executable is running?  Thanks in advance.


Wed, 04 Sep 2002 03:00:00 GMT  
 Detecting if Linux Program Running

Quote:

>Is there any easy way using Python under Linux to detect whether a
>particular executable is running?  Thanks in advance.

The easiest but not reliable way should be lock files (i.e.
files you usually find under /var/run). Process creates file,
process checks for file, story goes on. Actually this technique
is practiced by a whole lot of applications no matter if they
are written in Python or some other language.

I repeat though, it's not a reliable method.

--

National Technical University of Athens
Network Management Center
Tel. No: +30 1 7721861



Wed, 04 Sep 2002 03:00:00 GMT  
 Detecting if Linux Program Running

Quote:

>Is there any easy way using Python under Linux to detect whether a
>particular executable is running?  Thanks in advance.

Best tip is to check the output of "os.popen('ps')" .. to some this will
seem like cheating, but trust me it isn't. <wink>
Another way could be to poke around in the /proc-directory...

If you already have a pid and want to check if the program is running, you
can try to send it signal 0 by doing a "os.kill(pid,0)". This will raise an
OSError if this isn't a running process.

--

Stian Husemoen <stianh>



Wed, 04 Sep 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Detect if another program is running

2. API call to detect running programs

3. Detecting program running

4. VisualWorks Running Program Under Linux

5. VisualWorks Running Program under Linux

6. Recommendations for programming Network of Linux Workstations running MOSIX

7. How to run and program tcl/tk in redhat linux

8. modify program in linux then run on Windows

9. Run a linux program through python

10. Long running program, by short running expectk

11. program behaves differently when run from expectk than when run from sh

12. Detecting remote run of application - PC Anywhere

 

 
Powered by phpBB® Forum Software