472,958 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

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 3645
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Andreas Kuntzagk | last post by:
Hi, following code: #!/usr/bin/python import os import sys def main():
2
by: Hoegje | last post by:
I am writing a C++ program, which should create a sub- process to start a telnet session to another server. Then it should login to that server (on the telnet login) and execute one or more...
11
by: christopher diggins | last post by:
I am wondering if any can point me to any open-source library with program objects for C++ like there is in Java? I would like to be able to write things like MyProgram1 >> MyProgram2 >>...
1
by: Alexander N. Spitzer | last post by:
I am trying to write a program that will fork a process, and execute the given task... the catch is that if it runs too long, I want to clean it up. this seemed pretty straight forward with a...
4
by: rh0dium | last post by:
Hi all, I have a problem with putting a job in the background. Here is my (ugly) script which I am having problems getting to background. There are threads about doing python script.py & ...
2
by: Poly-poly man | last post by:
I am working on a GTK Midi player (timidgtk.sourceforge.net). As you can see, it's just a timidity frontend. With version 0.03, I'm trying to devel it to use SDL_sound to play the midis. First...
1
by: ohaqqi | last post by:
Hi guys, I'm still working on my shell. I'm trying to implement a function typefile that will take a command line input as follows: > type <file1> This command will implement a catenation of...
3
by: Dan Upton | last post by:
I have a Python script that does a fork/exec, so the parent process can get the child's PID and monitor /proc/PID/stat (on a CentOS system). Most of my processes' command lines are straightforward...
167
by: darren | last post by:
Hi I have to write a multi-threaded program. I decided to take an OO approach to it. I had the idea to wrap up all of the thread functions in a mix-in class called Threadable. Then when an...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.