Opened 16 years ago

Closed 16 years ago

#8998 closed (invalid)

stdin closed by become_daemon()

Reported by: unix.gurus@… Owned by: nobody
Component: Uncategorized Version: 1.0
Severity: Keywords:
Cc: unix.gurus@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In ./django/utils/daemonize.py the posix become_daemon() function contains this code:

si = open('/dev/null', 'r')
so = open(out_log, 'a+', 0)
se = open(err_log, 'a+', 0)
os.dup2(si.fileno(), sys.stdin.fileno())
os.dup2(so.fileno(), sys.stdout.fileno())
os.dup2(se.fileno(), sys.stderr.fileno())
# Set custom file descriptors so that they get proper buffering.
sys.stdout, sys.stderr = so, se

When si passes out of scope the desctructor ends up closing FD 0 (sys.stdin). If anything tries to read stdin it will get the contents of the next open()ed file.

sys.stdin = si should be sufficient to keep it in scope.

Change History (2)

comment:1 by anonymous, 16 years ago

comment:2 by anonymous, 16 years ago

Resolution: invalid
Status: newclosed

Sorry, this is not an issue unless the dup2 is preceeded by an os.close(sys.stdin.fileno()).

Note: See TracTickets for help on using tickets.
Back to Top