Bill Moseley wrote:
> If running a program with a fork/exec within a mod_perl handler (not the
> best thing to do in mod_perl) with the following code:
>
> my $pid = open( PROG, "-|" );
>
> if ($pid) {
> while (<PROG>) {
> [..]
> }
> close( PROG ) or log_message( "failed close on program $! $?");
>
> What's the proper way to close/kill PROG _early_ before PROG has finished
> with it's output. I keep getting SIGPIPE errors ($? = 13) returned if I
> close before PROG is finished.
>
> I could kill( 'HUP', $pid ), instead of calling close() but then would I
> leak file handles? Calling kill doesn't seem like a the best solution.
>
The SIGPIPE is coming from the child. If you can modify the child, something
like $SIG{'CHLD'}=sub{exit(0)}; in the child would probably do the trick.
Gerd