linux - perl hangs on exit (after closing a filehandle) -
I have found a function that is (less):
my $ file = IO :: File-> New ("| few_index"> and 1 ") or die" Can not open some_ command for writing: $! \ N "; ... undef $ file;
Right now I'm not writing anything at $ file
. There is currently no other operation on $ file
when I run the program, it does not exit properly I think the handle is off, but waiting for the shutdown process Used to be. strace
:
close (6) = 0 RT_signition (SIGHUP, {SIG_IGN}, {SIG_DFL}, 8) = 0 rt_sigaction (SIGINT, {SIG_IGN}, { SIG_DFL}, 8) = 0 rt_sigaction (SIGQUIT, {SIG_IGN}, {SIG_DFL}, 8) = 0 waiting4 (16861, ^ c & dd; incomplete ...>
What do I have to do to exclude the program?
EDIT: So far the suggestions have been given to use the library or eliminate the input stream via ctrl + d But I do not want to interact with this program in any way at this point. I want to end it without now any more IO is it possible?
Anf $ file
removes a reference calculation from file handles and makes it eligible for garbage collection. If $ file
is a regular file There is no handle for file handles and there is no other reference for file handles, this Uld function is documented in the IO :: file
. In this case, $ file
is a handle for a shell command, and there may be some other internal references for file handles that prevent it from being destroyed $ file- & gt; Using locked
is safe and makes your intent very clear.
To close the command when the file closes the handle is not working, you need a process ID if you
Apply a command like my ($ file, $ pid); $ Pid = open ($ file, "| some_command>> / dev / null 2> and 1");
Then you can kill
'TERM', $ pid;
At the end of your program. I do not know how to extract Process ID from return value of IO :: File :: new
.
Comments
Post a Comment