in reply to fork & END

Are you on Win32? File::Temp claims that it doesn't unlink things in child processes, but if you're on Win32, you're only getting a pseudo-fork (see perlfork).

In any case, one approach is just to tell File::Temp not to unlink things automatically (with UNLINK => 0) and do your own cleanup. It's hard to be more specific with suggestions without knowing how you're using File::Temp.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Replies are listed 'Best First'.
Re^2: fork & END
by tlm (Prior) on Sep 07, 2005 at 01:12 UTC

    Thanks.

    Are you on Win32? File::Temp claims that it doesn't unlink things in child processes...

    I'm having a hard time locating this in the docs. Grepping "child" got me nothing. What should I search for? (FWIW, I'm using version 5.8.6 of Perl, and version 0.14 of File::Temp.)

    My OS is Linux.

    The problem I'm having results from the CLEANUP option of File::Temp::tempdir, which I'm setting to 1.

    I guess I was wondering if there was a standard workaround for this kind of situation.

    the lowliest monk

      I think you may want to upgrade. See the ChangeLog for File::Temp. 0.15 improved forking support. If you look at the CPAN docs, there's a brief comment in a section at the very end called "forking".

      In writing File::pushd, I didn't set CLEANUP and used File::Path to remove the directory precisely when I wanted to (in my case, earlier than END). You could do that in your parent process after you reap all the children. But I'd try your script with a newer version of File::Temp and see if that resolves things for you.

      -xdg

      Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.