470,841 Members | 1,083 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,841 developers. It's quick & easy.

objects and fork command?

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});
}
}
Jul 19 '05 #1
1 3612
do************@yahoo.com (Doug Nichols) wrote in message news:<78**************************@posting.google. com>...
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});
}
}


What you appear to be doing looks like it should work. But you have
not posted real code.

Please post a minimal but complete script that you have actually run
and found to display the symptoms you describe.

This (and lots more) helpful advice can be found in the posting
guidelines that are regularly posted to the newsgroup that superceded
this one when this newsgroup ceased to exist many years ago (see FAQ).
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Andreas Kuntzagk | last post: by
11 posts views Thread by christopher diggins | last post: by
4 posts views Thread by rh0dium | last post: by
2 posts views Thread by Poly-poly man | last post: by
3 posts views Thread by Dan Upton | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.