I had a patch for tmda-ofmipd in tmda-1.0.3 that wrote a pid file
when run as root in the background.
Here is the forward port of that patch for tmda-1.1.12
I don't claim to be a python programer so there may be better ways
to do it.
Now if I could only figure out how to get the signal handler to
remove the .pid file when it exits.
--
Tim Rice Multitalents (707) 887-1469
[EMAIL PROTECTED]
#
# bin/tmda-ofmipd
# add pid file support
#
--- tmda-1.1.12/bin/tmda-ofmipd.old 2008-04-15 15:11:34.000000000 -0700
+++ tmda-1.1.12/bin/tmda-ofmipd 2008-07-11 17:39:17.187521006 -0700
@@ -989,6 +989,13 @@
If this option is not used, `~user/.tmda/config' will be assumed, but
see the --vhome-script option for qmail virtual domain users.""")
+gengroup.add_option("", "--pidfile",
+ default="/var/run/tmda-ofmipd.pid",
+ metavar="/PATH/TO/FILE", dest="pidfile",
+ help= \
+"""The file used to write the process ID if we run in background
+ mode. The default is /var/run/tmda-ofmipd.pid""")
+
# connection
congroup.add_option("-p", "--proxyport",
default="%s:%s" % (FQDN, 8025), metavar="HOST:PORT",
@@ -1184,6 +1191,8 @@
if not opts.authfile:
opts.authfile = '/etc/tofmipd'
ipauthmapfile = '/etc/ipauthmap'
+ if not opts.pidfile:
+ opts.pidfile = '/var/run/tmda-ofmipd.pid'
else:
tmda_path = os.path.join(os.path.expanduser('~'), '.tmda')
ipauthmapfile = os.path.join(tmda_path, 'ipauthmap')
@@ -1376,6 +1385,9 @@
if Util.getfileuid(opts.authfile) <> pw_uid:
raise IOError, \
opts.authfile + ' must be owned by UID ' + str(pw_uid)
+ if not (opts.foreground or opts.one_session):
+ pidf=open(opts.pidfile, 'w')
+ os.chmod(opts.pidfile, 0644)
# Set group ID
os.setegid(Util.getgid(opts.username))
# Set supplemental group ids
@@ -1391,7 +1403,11 @@
if True:
os.setsid()
- if os.fork() <> 0:
+ pid = os.fork()
+ if pid <> 0:
+ pidf.write(str(pid))
+ pidf.write('\n')
+ pidf.close()
sys.exit()
os.setpgrp()
_________________________________________________
tmda-workers mailing list ([email protected])
http://tmda.net/lists/listinfo/tmda-workers