Ticket #6849: 6849.diff
File 6849.diff, 1.2 KB (added by , 17 years ago) |
---|
-
django/utils/daemonize.py
1 1 import os 2 2 import sys 3 import codecs 3 4 4 5 if os.name == 'posix': 5 6 def become_daemon(our_home_dir='.', out_log='/dev/null', err_log='/dev/null'): … … 24 25 os._exit(1) 25 26 26 27 si = open('/dev/null', 'r') 27 so = open(out_log, 'a+', 0)28 se = open(err_log, 'a+', 0)28 so = codecs.open(out_log, 'a+', 'utf-8', 'replace', 0) 29 se = codecs.open(err_log, 'a+', 'utf-8', 'replace', 0) 29 30 os.dup2(si.fileno(), sys.stdin.fileno()) 30 31 os.dup2(so.fileno(), sys.stdout.fileno()) 31 32 os.dup2(se.fileno(), sys.stderr.fileno()) … … 43 44 sys.stdout.close() 44 45 sys.stderr.close() 45 46 if err_log: 46 sys.stderr = open(err_log, 'a', 0)47 sys.stderr = codecs.open(err_log, 'a', 'utf-8', 'replace', 0) 47 48 else: 48 49 sys.stderr = NullDevice() 49 50 if out_log: 50 sys.stdout = open(out_log, 'a', 0)51 sys.stdout = codecs.open(out_log, 'a', 'utf-8', 'replace', 0) 51 52 else: 52 53 sys.stdout = NullDevice() 53 54