Zielony has asked for the wisdom of the Perl Monks concerning the following question:
As you see, I have to close pipe SAPW, but I need it for next whiles.#!/usr/bin/perl -w use strict; use IO::Handle; use POSIX qw /mkfifo/; mkfifo "fifo", 0777 unless (-p "fifo"); pipe (PARENTR, SAPW); pipe (SAPR, PARENTW); SAPW->autoflush(1); PARENTW->autoflush(1); my $pid = fork; if ($pid) { close PARENTR; close PARENTW; while (1) { open FIFOR, "fifo"; my $line = <FIFOR>; close FIFOR; print SAPW $line; close SAPW; # don't want this print <SAPR>; } } else { close SAPR; close SAPW; open STDIN , '<&PARENTR'; open STDOUT, '>&PARENTW'; exec "cat"; die $!; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pipe autoflush
by almut (Canon) on Aug 23, 2007 at 12:33 UTC | |
by Zielony (Acolyte) on Aug 23, 2007 at 12:37 UTC | |
by almut (Canon) on Aug 23, 2007 at 15:57 UTC | |
by Zielony (Acolyte) on Aug 23, 2007 at 16:33 UTC | |
by almut (Canon) on Aug 23, 2007 at 20:04 UTC | |
| |
|
Re: Pipe autoflush
by technojosh (Priest) on Aug 23, 2007 at 14:18 UTC | |
by ikegami (Patriarch) on Aug 23, 2007 at 14:54 UTC |