Re: [Exim] Solaris 2.6, Perl 5.6.1, exim 3.22 - Can't open p…

Páxina inicial
Borrar esta mensaxe
Responder a esta mensaxe
Autor: Malcolm Beattie
Data:  
Para: Gustav H Meyer
CC: Philip Hazel, exim-users, Tamas TEVESZ
Asunto: Re: [Exim] Solaris 2.6, Perl 5.6.1, exim 3.22 - Can't open pipe
Gustav H Meyer writes:
> >> The close statement is as follows:
> >>     85  close(MAIL) or die "Can't close pipe to $sendmail: $!\n";

> >>
> >> As you can see the value of $! is passed on to the browser together
> >> with the message. But unfortunately I can see no value to speak of.
> >> In other words the value must be blank.

[...]
>    459 open(MAIL,"| $sendmail -t") or &error("Couldn't
> open sendmail process: $!");

[...]
>    472 close(MAIL) or &error("Can't close pipe to $send mail: $!");


I haven't been following this thread in detail but this caught my eye.
Do you realise that if the piped program exits with a non-zero return
code then close(MAIL) will return false and set $! to 0 numerically
(a blank string if you use it as a string)? It will also put the exit
code of the subprogram in $? for you. This is all documented:

    % man perlfunc
       close FILEHANDLE


       close   Closes the file or pipe associated with the file
           handle, returning true only if stdio successfully
    [...]
           If the file handle came from a piped open `close'
           will additionally return false if one of the other
           system calls involved fails or if the program
           exits with non-zero status.  (If the only problem
           was that the program exited non-zero `$!' will be
           set to `0'.)  Closing a pipe also waits for the
           process executing on the pipe to complete, in case
           you want to look at the output of the pipe after­
           wards, and implicitly puts the exit status value
           of that command into `$?'.


--Malcolm

--
Malcolm Beattie <mbeattie@???>
Unix Systems Programmer
Oxford University Computing Services