~ubuntu-branches/debian/sid/python-django/sid

« back to all changes in this revision

Viewing changes to django/utils/daemonize.py

  • Committer: Package Import Robot
  • Author(s): Raphaël Hertzog
  • Date: 2014-09-17 14:15:11 UTC
  • mfrom: (1.3.17) (6.2.18 experimental)
  • Revision ID: package-import@ubuntu.com-20140917141511-icneokthe9ww5sk4
Tags: 1.7-2
* Release to unstable.
* Add a migrate-south sample script to help users apply their South
  migrations. Thanks to Brian May.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import os
2
2
import sys
3
3
 
 
4
from . import six
 
5
 
 
6
buffering = int(six.PY3)        # No unbuffered text I/O on Python 3 (#20815).
 
7
 
4
8
if os.name == 'posix':
5
9
    def become_daemon(our_home_dir='.', out_log='/dev/null',
6
10
                      err_log='/dev/null', umask=0o022):
25
29
            os._exit(1)
26
30
 
27
31
        si = open('/dev/null', 'r')
28
 
        so = open(out_log, 'a+', 0)
29
 
        se = open(err_log, 'a+', 0)
 
32
        so = open(out_log, 'a+', buffering)
 
33
        se = open(err_log, 'a+', buffering)
30
34
        os.dup2(si.fileno(), sys.stdin.fileno())
31
35
        os.dup2(so.fileno(), sys.stdout.fileno())
32
36
        os.dup2(se.fileno(), sys.stderr.fileno())
44
48
        sys.stdout.close()
45
49
        sys.stderr.close()
46
50
        if err_log:
47
 
            sys.stderr = open(err_log, 'a', 0)
 
51
            sys.stderr = open(err_log, 'a', buffering)
48
52
        else:
49
53
            sys.stderr = NullDevice()
50
54
        if out_log:
51
 
            sys.stdout = open(out_log, 'a', 0)
 
55
            sys.stdout = open(out_log, 'a', buffering)
52
56
        else:
53
57
            sys.stdout = NullDevice()
54
58