Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Can't close pipe to invalid process

by aitap (Curate)
on Aug 29, 2015 at 16:05 UTC ( [id://1140402]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use Test::Simple tests => 3;
    ok !open(my $fh, '|-', 'nonexistent program'), 'string form of open fa
    +ils';
    ...
    ok 1 - string form of open fails
    ok 2 - but succeeds if shell uses redirection
    ok 3 - list form of open fails, as it should
    
  2. or download this
    $ strace -f -e clone,execve perl -e'open(my $fh, "|-", "nonexistent pr
    +ogram")'
    execve("/usr/bin/perl", ["perl", "-eopen(my $fh, \"|-\", \"nonexisten"
    +...], [/* 45 vars */]) = 0
    clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIG
    +CHLD, child_tidptr=0xb74f7a68) = 7792
    ...
    [pid  7792] +++ exited with 1 +++
    --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=7792, si_uid
    +=1000, si_status=1, si_utime=0, si_stime=0} ---
    +++ exited with 0 +++
    
  3. or download this
    $ strace -f -e clone,execve perl -e'open(my $fh, "|-", "nonexistent pr
    +ogram 2>/dev/null")'
    execve("/usr/bin/perl", ["perl", "-eopen(my $fh, \"|-\", \"nonexisten"
    +...], [/* 45 vars */]) = 0
    ...
    [pid  7809] +++ exited with 127 +++
    --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=7809, si_uid
    +=1000, si_status=127, si_utime=0, si_stime=0} ---
    +++ exited with 0 +++
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1140402]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2025-03-26 22:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (68 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.