Thanks, that does the trick.
Mike Meyer <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Yeah, but it takes work on both ends. You could wrap your mpg123 in a > shell script like so: > > #!/bin/sh > mpg123 "$@" & > echo $! >/tmp/mpg123.pid > > > Or in python 2.4: > > #!/usr/bin/env python > from subprocess import Popen > > p = Popen('mpg123') > pidfile = file('/tmp/mpg123.pid', 'w') > pidfile.write("%d" % p.pid) > pidfile.close() > > Then have your check program do (again, using the 2.4 subprocess > module) > > from subprocess import Popen, PIPE > > try: > pidfile = file('/tmp/mpg123.pid') > except IOError: > print 'mpg123 is dead' > else: > pid = pidfile.read() > t = Popen('ps p %s' % pid, shell=True, stdout=PIPE).stdout > if t.readlines() < 2: > print 'mpg123 is dead' > os.remove('/tmp/mpg123.pid') > return 0 > return 2 > > Basically, instead of trusting grep to find mpg123, save the pid in a > file and let ps find it (or not) by pid. > > <mike -- http://mail.python.org/mailman/listinfo/python-list