Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 12-12-2012, 08:20 AM   #1
LQ Newbie
Registered: Dec 2012
Posts: 2

Rep: Reputation: Disabled
Linux process(problem with wait)

Hi.I am beginner a Linux.I use C language & problem is about wait() function.I know this function waits the child's terminate to continue.I use wait(NULL) and parent waits the child.but I want the parent to wait the child when 'as' equal to zero.If 'as' isnt equal to zero ,the parent(in my code it is main) must not wait the child.But main always waits to continue.Where is the problem?
pid_t childpid;
childpid = fork();
int status;



if (childpid == -1)  {
       perror("Failed to fork\n");
       return 1; }

if (childpid == 0){

execl(cmd[0],cmd[1],cmd[2],cmd[3],cmd[4],cmd[5],cmd[6],cmd[7],cmd[8],cmd[9],cmd[10],cmd[11],cmd[12],cmd[13],cmd[14],cmd[15],cmd[16],cmd[17],cmd [18],cmd[19],cmd[20],cmd[21],cmd[22],cmd[23],cmd[24],cmd[25],cmd[26],cmd[27],cmd[28],cmd[29],cmd[30],NULL);

perror("Child failed to execl\n");

 if (childpid != wait(NULL)) {                  
       perror("Parent failed to wait due to signal or error\n");
       return 1;
Old 12-12-2012, 08:59 AM   #2
LQ Newbie
Registered: Dec 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
no help?
never thought of this, while being a Member


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
parent process to wait foe child process to comelet priyas Linux - Kernel 2 03-01-2012 09:52 AM
BASH: Waiting for a process to end, problem with wait patolfo Linux - General 2 03-20-2010 12:54 AM
How to wait for the process and know if the exit code of the sub process williamhomanchun Linux - General 10 08-11-2008 02:32 PM
Fortran and linux: Wait for process completion cooln Programming 3 07-23-2007 10:04 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:29 AM.

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