in reply to FileHandle->close() is not closing everything

If this is really the code you are executing, then no additional process is started. You're just opening a file with a very strange name.

However, I expect your real code does a pipe-open, and reads from it (or writes to it). A pipe-open is a complex process. A pipe is opened, the process forks, parent and child each close one end of the pipe (leaving a uni-directional pipe), and then the child does an exec. If you call close, Perl closes the pipe. It doesn't send a TERM signal, or something else to the child process. It's up to the child process how to deal with a closed pipe (most programs will exit, but some won't).

So you'll have to fix the OGG123 program, or do the termination from your program after the close yourself.

Abigail

  • Comment on Re: FileHandle->close() is not closing everything

Replies are listed 'Best First'.
Re: Re: FileHandle->close() is not closing everything
by Anonymous Monk on Mar 28, 2003 at 14:38 UTC
    Here's the actual code for the OPEN:
    } elsif (SliMP3::Info::isOgg($fullpath) && SliMP3::Prefs::get("transc +ode-ogg")) { # Note we have to put the path in double quotes so that # spaces in file names are handled properly. my $ogg_cmd = "ogg123 -q -p 5 -d raw -f - \"$filepath\""; my $lame_cmd = "lame -x -r - - &"; $client->mp3filehandle( FileHandle->new() ); $client->mp3filehandle->open("$ogg_cmd | $lame_cmd |");
    Here's the actual code for the CLOSE:
    # close the previous handle to prevent leakage. if (defined $client->mp3filehandle()) { $client->mp3filehandle->close(); $client->mp3filehandle(undef); $client->mp3filehandleIsSocket(0); }
    The OPEN is called when PLAY, NEXT, PREVIOUS is called. OPEN, always calls CLOSE to make sure that there are no running processes. So the code really does work that way. But I see your point about TERM.
      Well, it's doing just as I said, a pipe-open. A close() closes the pipe. Whether the program on the other ends terminate is up to said program, Perl will not take any attempts to kill the program off.

      Abigail