diff options
Diffstat (limited to 'certmaster/utils.py')
-rwxr-xr-x | certmaster/utils.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/certmaster/utils.py b/certmaster/utils.py index 588e986..22b0afb 100755 --- a/certmaster/utils.py +++ b/certmaster/utils.py @@ -44,10 +44,14 @@ def daemonize(pidfile=None): Writes the new PID to the provided file name if not None. """ - print pidfile +# print pidfile pid = os.fork() if pid > 0: sys.exit(0) + os.close(0) + os.close(1) + os.close(2) + os.cwd("/") os.setsid() os.umask(0) pid = os.fork() @@ -57,12 +61,15 @@ def daemonize(pidfile=None): open(pidfile, "w").write(str(pid)) sys.exit(0) + def nice_exception(etype, evalue, etb): - # FIXME: I believe we can remove this function etype = str(etype) - lefti = etype.index("'") + 1 - righti = etype.rindex("'") - nicetype = etype[lefti:righti] + try: + lefti = etype.index("'") + 1 + righti = etype.rindex("'") + nicetype = etype[lefti:righti] + except: + nicetype = etype nicestack = string.join(traceback.format_list(traceback.extract_tb(etb))) return [ REMOTE_ERROR, nicetype, str(evalue), nicestack ] |