~ubuntu-branches/ubuntu/saucy/python-django/saucy-updates

« back to all changes in this revision

Viewing changes to django/utils/daemonize.py

  • Committer: Package Import Robot
  • Author(s): Luke Faraone, Jakub Wilk, Luke Faraone
  • Date: 2013-05-09 15:10:47 UTC
  • mfrom: (1.1.21) (4.4.27 sid)
  • Revision ID: package-import@ubuntu.com-20130509151047-aqv8d71oj9wvcv8c
Tags: 1.5.1-2
[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

[ Luke Faraone ]
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
if os.name == 'posix':
5
5
    def become_daemon(our_home_dir='.', out_log='/dev/null',
6
 
                      err_log='/dev/null', umask=022):
 
6
                      err_log='/dev/null', umask=0o022):
7
7
        "Robustly turn into a UNIX daemon, running in our_home_dir."
8
8
        # First fork
9
9
        try:
10
10
            if os.fork() > 0:
11
11
                sys.exit(0)     # kill off parent
12
 
        except OSError, e:
 
12
        except OSError as e:
13
13
            sys.stderr.write("fork #1 failed: (%d) %s\n" % (e.errno, e.strerror))
14
14
            sys.exit(1)
15
15
        os.setsid()
20
20
        try:
21
21
            if os.fork() > 0:
22
22
                os._exit(0)
23
 
        except OSError, e:
 
23
        except OSError as e:
24
24
            sys.stderr.write("fork #2 failed: (%d) %s\n" % (e.errno, e.strerror))
25
25
            os._exit(1)
26
26
 
33
33
        # Set custom file descriptors so that they get proper buffering.
34
34
        sys.stdout, sys.stderr = so, se
35
35
else:
36
 
    def become_daemon(our_home_dir='.', out_log=None, err_log=None, umask=022):
 
36
    def become_daemon(our_home_dir='.', out_log=None, err_log=None, umask=0o022):
37
37
        """
38
38
        If we're not running under a POSIX system, just simulate the daemon
39
39
        mode by doing redirections and directory changing.