[Bps-public-commit] app-wsgetmail branch, move-close-after-warn, created. 31d5bcaaa460f61f6b2dfc5fc640da640f5f2dd9

Blaine Motsinger blaine at bestpractical.com
Tue Mar 30 15:52:17 EDT 2021


The branch, move-close-after-warn has been created
        at  31d5bcaaa460f61f6b2dfc5fc640da640f5f2dd9 (commit)

- Log -----------------------------------------------------------------
commit 31d5bcaaa460f61f6b2dfc5fc640da640f5f2dd9
Author: Blaine Motsinger <blaine at bestpractical.com>
Date:   Tue Mar 30 14:43:18 2021 -0500

    Move close fh after warn for correct error strings
    
    Reading the exit and error string values should be immediately
    after the syscall we're wanting values for, else risks another
    syscall setting them to something else.
    
    In the case of _run_command we want to read $! and $? for the
    command being run through IPC run, not the values from close.

diff --git a/lib/App/wsgetmail/MDA.pm b/lib/App/wsgetmail/MDA.pm
index 78964c1..7258b7b 100644
--- a/lib/App/wsgetmail/MDA.pm
+++ b/lib/App/wsgetmail/MDA.pm
@@ -75,8 +75,6 @@ sub _run_command {
         return 1;
     }
     my $ok = run ([ $self->command, _split_command_args($self->command_args, 1)], $fh, \$output, \$error, timeout( $self->command_timeout + 5 ) );
-    close $fh;
-
     unless ($ok) {
         warn sprintf('failed to run command "%s %s" for file %s : %s : %s',
                      $self->command,
@@ -84,7 +82,7 @@ sub _run_command {
                      $filename, $!, $?);
         warn "output : $output\nerror:$error\n" if ($self->debug);
     }
-
+    close $fh;
     return $ok;
 }
 

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list