ocehb: (Default)
[personal profile] ocehb
Вот что бывает, когда не маскируют глобальные переменные:

# perl -MNet::SCP::Expect -le 'print $?; $out = `ping -c1 localhost`; print $?;'
0
-1
#


из "perldoc -f waitpid":
waitpid PID,FLAGS
      Waits for a particular child process to terminate and returns the pid
      of the deceased process, or "-1" if there is no such child process.
      On some systems, a value of 0 indicates that there are processes still
      running.  The status is returned in $?.




--- Expect.pm.orig      2006-07-06 15:49:48.296813218 +0300
+++ Expect.pm   2006-07-06 16:04:58.845077068 +0300
@@ -13,7 +13,7 @@
 use Carp;
 use Cwd;

-$SIG{CHLD} = \&reapChild;
+local $SIG{CHLD} = \&reapChild;

 BEGIN{
    use vars qw/$VERSION/;
@@ -271,6 +271,7 @@
 }

 sub reapChild{
+   local $?;
    do {} while waitpid(-1,WNOHANG) > 0;
 }
 1;

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

Profile

ocehb: (Default)
ocehb

January 2021

S M T W T F S
     12
345 6789
10111213141516
17181920212223
24252627282930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 6th, 2026 01:05 am
Powered by Dreamwidth Studios