LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 07-14-2005, 02:45 AM   #1
tuxfood
Member
 
Registered: Aug 2003
Location: kerala , India
Distribution: RH9 , FC1 ,
Posts: 141

Rep: Reputation: 15
Help with undefined behavior of signal system call!!!


hi....


I read abt a method to make a parent process wait() for all its children to exit before it can exit using the signal system call...

It involved setting the action for the SIGCHLD signal to SIG_IGN (ignore)

So what i did was
Code:
    signal(SIGCHLD,SIG_IGN);
     
     /****  The forking stuff ****/


    ret = wait(&wait_val) ;
As per the book what should happen is that the signal SIGCHLD should be ignored and so on recieving the signal the parent just ignores the signal and continues to wait... until all the children have exited... .. When there are no more processes the wait system call returns


But as per the man page signal(2) tells that behavior of SIGCHLD signal with SIG_IGN set is undefined

Is there any way to rectify this???

tuxfood
 
Old 07-14-2005, 06:48 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
To me it makes more sense, to do it the other way around:
Leave the SIGCHLD as it is.
Call wait() in a loop until it returns -1 with errno == ECHILD.
Then the process will not have any child-processes anymore.

(errno ECHILD means: The calling process does not have any unwaited-for children.)
 
Old 07-15-2005, 11:31 PM   #3
tuxfood
Member
 
Registered: Aug 2003
Location: kerala , India
Distribution: RH9 , FC1 ,
Posts: 141

Original Poster
Rep: Reputation: 15
hi...

i actually did it as u have said before i read abt the method....


thnks anyway.... any idea why this behavior has been kept undefined???
 
  


Reply



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
PHP Call to undefined function imagettfbbox() QtCoder Programming 24 01-18-2012 12:20 PM
Call to undefined function mail() The_Lance SUSE / openSUSE 1 04-12-2005 08:55 AM
Call to undefined function domxml_open_mem() apt Programming 2 04-01-2005 03:25 AM
Call to undefined function: mysql_connect() SocialEngineer Linux - Software 2 11-16-2004 02:24 PM
Call to undefined function: mail() in PHP pembo13 Fedora 0 07-28-2004 07:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:36 AM.

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