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

Minor enhancement for IO::Pipe

Thread Next
Philip Prindeville
November 6, 2015 03:30
Minor enhancement for IO::Pipe
Message ID:
I was working on a program where I opened an IO::Pipe and ran “ip -o xfrm monitor” inside it…  Which would never terminate on its own, normally.

When the parent program caught a signal and wanted to clean up, it would normally kill() the child with SIGTERM and then reap it with $pipe->close().

Unfortunately, there’s no easy way to get the child’s pid.

Could we add a method to do so?

Something like:

package IO::Pipe::End;


sub pid
    my $fh = shift;

    return (defined ${*$fh}{‘io_pipe_pid’} ? ${*$fh}{‘io_pipe_pid’} : undef);

Alternatively, maybe add a method to clean up the child… though it’s not always clear what signal the child process should be killed with (maybe it’s best to leave that to the programmer).



Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About