terminating fifo in perl

Discussion in 'Perl Misc' started by Peng Yu, Dec 6, 2012.

  1. Peng Yu

    Peng Yu Guest

    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";



    --
    Regards,
    Peng
     
    Peng Yu, Dec 6, 2012
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charles A. Lackman

    Terminating a thread from the main thread

    Charles A. Lackman, Dec 9, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    1,771
    Herfried K. Wagner [MVP]
    Dec 9, 2004
  2. Kristofer Liljeblad

    Terminating a authenticated user

    Kristofer Liljeblad, Jun 30, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    546
    Kristofer Liljeblad
    Jun 30, 2003
  3. Hiren Patel
    Replies:
    2
    Views:
    585
    Hiren Patel
    Feb 1, 2005
  4. darrel

    terminating multiple try/catches

    darrel, Apr 4, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    588
    Eric Newton
    Apr 6, 2005
  5. chaitu
    Replies:
    0
    Views:
    1,206
    chaitu
    May 31, 2007
  6. chaitu
    Replies:
    1
    Views:
    1,146
    Mike Treseler
    May 31, 2007
  7. chaitu
    Replies:
    1
    Views:
    901
    quantum_dot
    Jun 1, 2007
  8. chaitu
    Replies:
    1
    Views:
    825
Loading...