terminating fifo in perl

P

Peng Yu

Hi,

Calling main.sh will hang. I think that this is related with the fifo.
Does anybody know a way to make the code finish without hanging?
Thanks!

~/linux/bin/xplat/src/coreutils/backup/headbody/perl/fifo/main$ cat
main.sh
#!/usr/bin/env bash

rm -rf head body
mkfifo head body
seq 10 | ../headbody.pl head body &
cat head body &
wait

~/linux/bin/xplat/src/coreutils/backup/headbody/perl/fifo/main$ cat ../
headbody.pl
#!/usr/bin/env perl

use strict;
use warnings;

#use FindBin;
#use lib "$FindBin::Bin/.";

open(HEAD, '>', $ARGV[0]) or die "cannot to open $ARGV[0] $!";
open(BODY, '>', $ARGV[1]) or die "cannot to open $ARGV[0] $!";

my $head = <STDIN>;
print HEAD $head;
close(HEAD) or die "cannot to close $ARGV[0] $!";

print STDERR "head";

while(<STDIN>) {
print BODY;
}
close(BODY) or die "cannot to close $ARGV[1] $!";

print STDERR "body";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,821
Messages
2,569,748
Members
45,726
Latest member
RaleighAll

Latest Threads

Top