Chris Angelico <ros...@gmail.com>: > On Sat, Oct 7, 2017 at 4:05 AM, Grant Edwards <grant.b.edwa...@gmail.com> > wrote: >> On 2017-10-06, Thomas Jollans <t...@tjol.eu> wrote: >>> Seriously? sys.stdin can be None? That's terrifying. >> >> Why? >> >> Unix daemons usually run with no stdin, stderr, or stdout. >> >> And yes, people do write Unix daemons in Python. > > Hmm, but usually I would expect them still to HAVE those streams, > they're just connected to /dev/null or something. I don't think they > would actually fail to exist, would they?
The reason a daemon usually opens dummy file descriptors for the 0, 1 and 2 slots is to avoid accidents. Some library might assume the existence of those file descriptors. For example, I often see GTK print out diagnositic messages. It would be awkward if those file descriptor slots were assigned to, say, a database or a socket. Marko -- https://mail.python.org/mailman/listinfo/python-list