LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 08-28-2010, 01:58 PM   #1
whirlpool
LQ Newbie
 
Registered: Aug 2010
Posts: 11

Rep: Reputation: 3
Exclamation How to make sure no orphans are created?


Iv been trying to solve a problem using C language.Iv worked out the logic. But being new to the linux commands Iv not been able to code it .There are two parts to my problem.

1) The first being, the parent process should create as many children (i.e.using fork() ) as desired by the user at run time without any of the children beginning their execution.
Here is what I thought : Stopping children from execution could be done using the condition if(fork()==0) { <the command to stop>)
Would sigstop be the command ?
Im unsure about it as I want the children to only stop their execution till the time parent finishes creating children. After which the children should begin their execution.



2) The second glitch where I'm stuck is , I do not want any orphans to be created so, a parent should enter a wait state till all it's children have finished execution. And then the parent can die.
How to implement this ? How do we enter and exit from wait states for specific pids? (the children's pid .. in this case ).


Please correct me if I'm on the wrong line of thought.

Thanks
 
Old 08-28-2010, 02:29 PM   #2
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by whirlpool View Post
I want the children to only stop their execution till the time parent finishes creating children...Would sigstop be the command ?
Welcome to LQ !

Check out the following links:
wait()
1. http://manpages.courier-mta.org/htmlman2/wait.2.html
2. http://www.csl.mtu.edu/cs4411/www/NO...fork/wait.html
3. http://www.yolinux.com/TUTORIALS/ForkExecProcesses.html

sig family:
1. http://www.supercomputing.it/At_Cile.../sigset.2.html

Read these detailed descriptions, see if that helps !
 
1 members found this post helpful.
Old 08-29-2010, 12:23 AM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Moved: This thread is more suitable in <PROGRAMMING> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 08-29-2010, 01:33 AM   #4
whirlpool
LQ Newbie
 
Registered: Aug 2010
Posts: 11

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by anishakaul View Post
Thanks a lot! It's with the help of people like you that beginners get encouraged to learn more.
 
Old 08-29-2010, 04:35 AM   #5
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by whirlpool View Post
Thanks a lot! It's with the help of people like you that beginners get encouraged to learn more.
I am really glad I could be of some help to you ! and you formed the question really well. Keep it up !

Last edited by Aquarius_Girl; 08-29-2010 at 05:02 AM. Reason: typo
 
  


Reply


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
urpme --auto-orphans failed mikieboy Mandriva 1 01-08-2010 12:38 PM
I created a c .so object, and can link successfully, now I want to make it for c++ morty346 Programming 4 06-11-2009 10:24 AM
Howto delete orphans 2007.1 Kde drifwood Mandriva 3 10-08-2007 11:18 AM
LXer: Xandros 4: relief for Windows 98/ME orphans LXer Syndicated Linux News 7 08-06-2006 04:08 PM
Make newly created file executable Black Chaos Linux - General 3 08-03-2006 10:53 AM

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

All times are GMT -5. The time now is 03:47 PM.

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