I have an object that is created that does a fork. The parent needs to
remove the lock file it created when it is complete, but the child
processes will not really have any files to remove.
The problem is the parent doesn't seem to delete the files- like the
DESTROY never happens. when the parent end.
What gives??
Thanks in advance.
dn
--- file testa
sub new {
my $self = shift;
$self = { LOCK_FILE => 'this.pid', };
bless $self;
if (my $pid = fork()) { parent stuff....
finihs end exit!
} elsif (defined($pid)) { child stuff....
go do something for while....
exit 0;
} els........
return $self;
}
sub DESTROY {
my $self = shift;
my $pid = $1 if (`cat $self->{LOCK_FILE}` =~ /\D*(\d+)\D*/);
if ($$ == $pid) {
unlink ($self->{LOCK_FILE});
}
}