~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/chat.py

ivle.chat now closes all file descriptors when daemonising.

This lets usrmgt-server not break postinsts, but more importantly stops
python-console from breaking Apache. Yes, that's finally fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
            os._exit(0) # kill off parent again.
54
54
        os.umask(077)
55
55
 
 
56
        try:
 
57
            MAXFD = os.sysconf("SC_OPEN_MAX")
 
58
        except:
 
59
            MAXFD = 256
 
60
 
 
61
        # Close all file descriptors, except the socket.
 
62
        for i in xrange(MAXFD):
 
63
            if i == s.fileno():
 
64
                continue
 
65
            try:
 
66
                os.close(i)
 
67
            except OSError:
 
68
                pass
 
69
 
56
70
    if initializer:
57
71
        initializer()
58
72