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. %
In reply to Re^2: Deleting a file after it runs?
by liverpole
in thread Deleting a file after it runs?
by Spidy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |