develooper Front page | perl.perl5.porters | Postings from February 2015

Re: [perl #123775] Args to 'system' not evaluated before forking,making $$ wrong

Thread Previous | Thread Next
From:
Leon Timmermans
Date:
February 15, 2015 01:09
Subject:
Re: [perl #123775] Args to 'system' not evaluated before forking,making $$ wrong
Message ID:
CAHhgV8jW1VPFh7Yz5O7Pt_qrDfN3Gyv2Q0OHj2CwUgLn2-XQTA@mail.gmail.com
From c2d16f4e6465f8bfd392400a80c816ac90dc1dfe Mon Sep 17 00:00:00 2001
From: Leon Timmermans <fawaka@gmail.com>
Date: Sat, 14 Feb 2015 15:43:07 +0100
Subject: [PATCH 2/2] Simplify system $$ tests

---
 t/op/exec.t | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/t/op/exec.t b/t/op/exec.t
index d5ec32e..f26b8fd 100644
--- a/t/op/exec.t
+++ b/t/op/exec.t
@@ -153,22 +153,14 @@ TODO: {
         "exec failure doesn't terminate process");
 }
 
-SKIP: {
-    skip 'Doesn\'t work on Windows/VMS', 2 if $Is_VMS || $Is_Win32;
-    open my $fh, '-|', 'echo', $$;
+{
+    my @echo = $Is_VMS ? ($Perl, '-le', 'print $ARGV[0]') : 'echo';
+    open my $fh, '-|', @echo, $$;
     my $pid = <$fh>;
     chomp $pid;
     is($pid, $$, 'Pid is as expected in openpipe');
 
-    skip 'Can\'t load POSIX' if not eval { require POSIX };
-    if (my $child = open my $fh, '-|') {
-        my $pid = <$fh>;
-        chomp $pid;
-        is($pid, $child, 'Pid is as expected in system');
-    } else {
-        system 'echo', $$;
-        POSIX::_exit(0);
-    }
+    ok(!system($Perl, '-e', 'exit ($ARGV[0] eq $$)', $$), 'Pid is as expected in system');
 }
 
 my $test = curr_test();
-- 
2.2.0-369-g3b010e3


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About