in reply to Re: Deleting a file after it runs?
in thread Deleting a file after it runs?
The removal is completed and disk space released once your program closes.
I believe the removal is happening even earlier -- after the program has compiled, and the Perl interpreter has started executing it, but potentially long before the program completes. Try this to see what I mean:
And when you run it:#!/usr/bin/perl -w + # Strict use strict; use warnings; + # Main program print "Check file before unlink\n"; sleep 1; system("ls $0"); print "Unlinking the file $0\n"; sleep 1; unlink $0; print "Check file after unlink\n"; sleep 1; system("ls $0"); + print "File should be now be gone from disk (but still in memory)\n"; print "Try ^Z and check it with 'ls $0' ... (come back with 'fg')\n"; sleep 10; + print "I'm still here, but the original file is long gone.\n";
% chmod +x rmtest % rmtest Check file 'rmtest' before unlink rmtest Unlinking the file 'rmtest' Check file 'rmtest' after unlink ls: rmtest: No such file or directory File should be now be gone from disk (but still in memory) Try ^Z and check it with 'ls rmtest' ... (come back with 'fg') Suspended % ls rmtest ls: rmtest: No such file or directory % fg rmtest I'm still here, but the original file is long gone. %
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Deleting a file after it runs?
by Tanktalus (Canon) on Oct 07, 2005 at 03:40 UTC | |
by liverpole (Monsignor) on Oct 07, 2005 at 16:34 UTC | |
by Hue-Bond (Priest) on Oct 07, 2005 at 19:44 UTC |