/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Teddy Hogeborn
  • Date: 2008-09-05 18:37:28 UTC
  • Revision ID: teddy@fukt.bsnet.se-20080905183728-l0m8v3vqa302uwrw
* mandos (main): Use EAFP with pidfile.

Show diffs side-by-side

added added

removed removed

Lines of Context:
773
773
                                settings=server_settings,
774
774
                                clients=clients)
775
775
    pidfilename = "/var/run/mandos.pid"
776
 
    pidfile = None
777
776
    try:
778
777
        pidfile = open(pidfilename, "w")
779
778
    except IOError, error:
848
847
        # Close all input and output, do double fork, etc.
849
848
        daemon()
850
849
    
851
 
    if pidfile is not None:
 
850
    try:
852
851
        pid = os.getpid()
853
 
        try:
854
 
            pidfile.write(str(pid) + "\n")
855
 
            pidfile.close()
856
 
        except IOError, err:
857
 
            logger.error(u"Could not write %s file with PID %d",
858
 
                         pidfilename, os.getpid())
859
 
    del pidfile
 
852
        pidfile.write(str(pid) + "\n")
 
853
        pidfile.close()
 
854
        del pidfile
 
855
    except IOError, err:
 
856
        logger.error(u"Could not write to file %r with PID %d",
 
857
                     pidfilename, pid)
 
858
    except NameError:
 
859
        # "pidfile" was never created
 
860
        pass
860
861
    del pidfilename
861
862
    
862
863
    def cleanup():