Review your favorite Linux distribution.
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 05-26-2006, 03:49 AM   #1
LQ Newbie
Registered: Oct 2005
Posts: 28

Rep: Reputation: 15
waiting for a child process to finish execution in C

I have forked a child process from my main process. I want my main pgm to wait till the child finishes execution. I thought of using wait_pid() function in wait.h. But an error is comming

undefined reference to `wait_pid'.

If i am using this wait_pid(), where should i write this, before fork() or after fork()?

I want to know how to use this wait_pid() function. If there is any other way to wait for the completion of the child process please tell me that also

thanks and regards
Old 05-26-2006, 04:44 AM   #2
Senior Member
Registered: Feb 2006
Location: Siberia
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705

Rep: Reputation: 54
man waitpid
Old 05-26-2006, 04:58 AM   #3
Registered: May 2006
Location: India
Distribution: Redhat
Posts: 49

Rep: Reputation: 15
int status;
int pid=fork();
/*error code*/
else if(pid==0)
/*do child work here*/
/* parent work */


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
how a father process know which child process send the signal SIGCHLD icoming Programming 10 07-20-2010 08:26 AM
How to kill a Child and all its subsequent child process in C shayer009 Programming 3 12-04-2007 01:40 AM
process and child process in java xhi Programming 4 03-28-2006 11:36 AM
Killing a child process from another child marri Programming 6 10-01-2004 08:08 PM
Bash Scripting - child process affecting parent process mthaddon Linux - General 1 05-02-2004 02:19 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:54 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
Open Source Consulting | Domain Registration