Interactive scripts (back on topic for once) [was Re: The "loop and a half"]

Marko Rauhamaa marko at pacujo.net
Fri Oct 6 14:01:51 EDT 2017


Chris Angelico <rosuav at gmail.com>:

> On Sat, Oct 7, 2017 at 4:05 AM, Grant Edwards <grant.b.edwards at gmail.com> wrote:
>> On 2017-10-06, Thomas Jollans <tjol at 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



More information about the Python-list mailing list