[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fifo Problem
From: |
Francis Montagnac |
Subject: |
Re: Fifo Problem |
Date: |
Mon, 08 Jul 2002 15:40:46 +0200 |
Hi,
>> create_pipes() {
>> echo "create 4> pipe out"
>> ftp_pipe_out=/tmp/ftp_pipe_out.$$ #create the output fifos
>> mkfifo $ftp_pipe_out
>> exec 4>$ftp_pipe_out <-----------
>> echo "leaving create 4> pipe out"
>> }
>>
>> It never leaves create_pipes. It get stuck on the exec.
> Opening a fifo for writing blocks until there's something trying to read
> from it. See if open(2), mknod(2), or fifo(4) shed more light.
Yes. You have to be careful on the order followed when opening fifos.
The following will work:
mkfifo in
mkfifo out
ftp < in > out &
# Now the previous sub-process is blocked trying to open in
exec 4> in # The subprocess succeeds now to open in
exec 5< out # Same for out, ftp is started by the sub-process
# Now you can freely read from 5 and write to 4
--
Francis.Montagnac@sophia.inria.fr, Tel: (33) 04 92 38 79 11, Bur: E106
INRIA Sophia, 2004, rte des Lucioles, B.P.93 - 06902 Sophia Antipolis Cedex