[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Problems with PERL 5.10 and system pipe



Alex Muntada wrote:
> + Damyan Ivanov <dmn@debian.org>:
> 
>> (i.e. no hang even on reads)
>> And this doesn't read from the pipe even if I do "echo some > test"
>> beforehand. Something is not right.
> 
> O_NONBLOCK means non-blocking I/O at all, even for read.
> 
> This works as expected:
> 
> $ perl -MFcntl -we 'use autodie; use strict; sysopen(PH, "test",
>   O_NONBLOCK); while (1) { print readline(PH); sleep 1 }'

You should also be able to remove the NONBLOCK after the open
(fnct() with the F_SETFL command in C, it probably exists a binding in perl)

The blocking opening of a fifo is a standard behavior and documented:
man fifo
[...]  The FIFO  must  be  opened  on
       both  ends  (reading and writing) before data can be passed.  Normally,
       opening the FIFO blocks until the other end is opened also.

       A process can open a FIFO in non-blocking mode.  In this case,  opening
       for  read only will succeed even if no-one has opened on the write side
       yet, opening for write only will fail with ENXIO  (no  such  device  or
       address) unless the other end has already been opened.
[...]

  Regards,
    Vincent

> And afterwards:
> 
> $ echo foobar > test
> 
> HTH
> 


-- 
Vincent Danjean       GPG key ID 0x9D025E87         vdanjean@debian.org
GPG key fingerprint: FC95 08A6 854D DB48 4B9A  8A94 0BF7 7867 9D02 5E87
Unofficial pacakges: http://moais.imag.fr/membres/vincent.danjean/deb.html
APT repo:  deb http://perso.debian.org/~vdanjean/debian unstable main


Reply to: