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

Minor enhancement for IO::Pipe

Thread Next
From:
Philip Prindeville
Date:
November 6, 2015 03:30
Subject:
Minor enhancement for IO::Pipe
Message ID:
83F60FAC-8983-4F9E-A319-A4826EAF4995@cpan.org
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).

Thanks!

-Philip


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About