473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 3652
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.