w3ntp has asked for the wisdom of the Perl Monks concerning the following question:

I am using a Open of a piped process to put a process in the background as follows:

open( PROGRAMHANDLE, -|$NeilsProgram) some code close (PROGRAMHANDLE) more code stuff

This program works great under Perl 5.03/Solaris 7 but hangs with the Perl 5.8 on Solaris 9. Is there another way to kill this program, don't care if it does not gracefully die, so long as it dies and not hang up the rest of the code.

thanks
w3ntp

Replies are listed 'Best First'.
Re: close not working with opened piped fork process on solaris 9
by dragonchild (Archbishop) on Mar 30, 2004 at 02:10 UTC
    I'm having similar problems with mod_perl-1.99_13 with the APR and bare socket stuff. Stas was very confused. I, too, am using 5.8.0 on Solaris9. Thoughts, anyone?

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

Re: close not working with opened piped fork process on solaris 9
by Vautrin (Hermit) on Mar 30, 2004 at 02:48 UTC

    It seems to me that it may make sense to create a Perl wrapper for whatever program you are using. Have the wrapper open up the file handle to the piped process, then have it listen on a socket of your favorite flavor. Have your main program open up the socket, and when the connection is closed have the wrapper exit. If it still hangs, send the pid (in the special variable $$) over the pipe after opening the socket, and kill it by Pid.

    Out of curiousity, have you set $| = 1;? Also, is the program you are piping to Open Source? You may be able to create a full fledged wrapper if it is (i.e. use Inline::C to compile the program in a way you can call) That, or you could change the program to listen on a socket. Although, that might not be as easy as a wrapper.


    Want to support the EFF and FSF by buying cool stuff? Click here.