Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-19-2011, 09:54 AM   #1
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
Perl wait issue

I have a perl module in which I am trying to do some clean up activity in the END block. But prior to do this cleanup activity, I would like to wait for all the child(ren) of the process using this Module.

So I did something like

  my $pid = wait; 
  #### Do the clean up stuff here
The issue I am facing here is that call to wait is setting up the status var ($?) to -1 in case there are no child of the current process. Which is in line with the definition of wait in man 2.

Is there a way I can ignore this setting of $? by wait ?
Old 10-20-2011, 06:43 AM   #2
Senior Member
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,278

Rep: Reputation: 994Reputation: 994Reputation: 994Reputation: 994Reputation: 994Reputation: 994Reputation: 994Reputation: 994
Originally Posted by PMP View Post
Is there a way I can ignore this setting of $?
It is very easy to ignore the value of a variable... or I don't understand your question.
Old 10-20-2011, 07:05 AM   #3
Registered: Apr 2011
Location: UK
Distribution: Kubuntu 11.10
Posts: 562

Rep: Reputation: 102Reputation: 102
I'm not sure I understand the need to ignore $? either. You can just reassign it to give the exit code you want:
$? = 0;
But I'm concerned about the wait logic: could you have more than one child process? wait will return when any child process ends - and in other cases as well. You probably want something more like
while (wait() != -1) {}


perl, status, wait

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Read from stdin in perl, do not wait for EOF smeezekitty Programming 1 04-28-2010 03:17 PM
Perl datescript Issue, missing perl module? stefaandk Programming 5 02-19-2006 10:55 PM
Perl: Wait for ssh connection to close kenneho Programming 9 10-29-2005 09:19 AM
perl with BerkeleyDB issue? Xstack Programming 0 06-03-2005 07:09 PM
perl issue moonloader Slackware 2 03-27-2004 01:07 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:37 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration