O_NONBLOCK for pipes

Artem Khodush greenkaa@mail.ru
Mon Sep 22 13:14:00 GMT 2003


> >I have straightforward patch, containing about 20 lines of new code,
> >which implements O_NONBLOCK fcntl for pipes using
> >SetNamedPipeHandleState NT API call.
> >
> >Two questions before I send it:
> >
> >Will it be considered trivial, so that copyright assignement is not
> >required?
> 
> No, sorry.

OK, then it will take some time..

> >Is there some deep reason, which I don't see, why this was not
> >implemented before?
> 
> What does it buy you?  O_NONBLOCK is already implemented for pipes
> without this call, AFAIK.

Long story short: I've got a testcase which deadlocks on cygwin, 
but works on linux and with my patch on cygwin too. 
It's distilled from one of the tests for IPC::Run perl module, 
namely t/run.t, one which contains the line    
$r = run [ $perl, qw{-e print"-"x20000;<STDIN>;} ], \$in, \$out ;

The test forks a child which writes 20k of data to stdout then reads stdin,
then goes into the select loop in which writes (in a single call)
20k of data to child's stdin, and reads child's stdout until child exits.
If the amount of data written to child's stdin in a single call 
is longer then the size of cygwin's pipe buffer, you've got a deadlock.

That's why I decided that O_NONBLOCK for pipes on cygwin was 
not implemented.

Artem.




More information about the Cygwin-patches mailing list