[Python-ideas] Tulip / PEP 3156 - subprocess events

Oleg Broytman phd at phdru.name
Fri Jan 18 22:25:31 CET 2013


On Fri, Jan 18, 2013 at 09:01:32PM +0000, Paul Moore <p.f.moore at gmail.com> wrote:
> Hmm, I'm looking at a pipe transport on Unix, and I find I don't know
> enough about programming Unix. How do I set a file descriptor
> (specifically a pipe) in Unix to be nonblocking? For a socket,
> sock.setblocking(False) does the job. But for a pipe/file, the only
> thing I can see is the O_NONBLOCK flag to os.open/os.pipe2. Is it not
> possible to set an already open file descriptor to be nonblocking?

http://linuxmanpages.com/man2/fcntl.2.php

The file status flags
    A file descriptor has certain associated flags, initialized by open(2)
    and possibly modified by fcntl(2). The flags are shared between copies
    (made with dup(2), fork(2), etc.) of the same file descriptor.

    The flags and their semantics are described in open(2).

    F_GETFL
        Read the file descriptor's flags.
    F_SETFL
        Set the file status flags part of the descriptor's flags to the
        value specified by arg. Remaining bits (access mode, file creation
        flags) in arg are ignored. On Linux this command can only change the
        O_APPEND, O_NONBLOCK, O_ASYNC, and O_DIRECT flags.

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            phd at phdru.name
           Programmers don't die, they just GOSUB without RETURN.



More information about the Python-ideas mailing list