A way for closing an app monitor

Daniel Crespo dcrespo at gmail.com
Tue Nov 15 09:49:48 EST 2005


Hello,

I'm in the way for creating an application and its monitor. Yes, there
are 2 applications: The main app, and a monitor. The last one monitors
the main application for keeping it alive, and viceversa. But if I
close the main app, I want to close the monitor.

That is very easy under nt systems, but in 98 is a little more tricky
because of the problem with closing processes.

For example, I can't use the following code on a win98 machine:

def FindPID(exename):
    """
    usage:
    pid=FindPID("pythonw.exe")
    print pid
    """
    a = os.popen4('tasklist /FI "IMAGENAME eq '+exename+'"')
    a[0].flush()
    try:
        info=a[1].readlines()[3].split()
    except:
        info=[exename,"NotFound"]
    return info[1] #PID

because the "tasklist" command doesn't exist on win98. Also, I tried to
install the kill.exe and a dont-remember-dll (from the Win98 Resource
Kit), but it doesn't work.

So my solution (need help on this) is that I have been thinking on
letting the monitor listen for socket connection. Through this, the
main app can tell him to close when the main app closes correctly. Do
you think this is well thought? Any suggestions?

Daniel




More information about the Python-list mailing list