The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Get both PID and exit status of a child process DarioHendrix Shell Programming and Scripting 2 02-26-2009 06:30 PM
Exit from n th child shell indra_saha UNIX for Dummies Questions & Answers 4 09-26-2008 05:48 AM
Getting exit status of child in trap handler rimon Shell Programming and Scripting 4 06-17-2008 01:05 AM
Can a child process return a specific value to a parent process ? Ametis1970 High Level Programming 8 04-09-2008 11:22 PM
gdb to child process shriashishpatil UNIX for Advanced & Expert Users 4 12-12-2005 07:57 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 07-03-2009
p00ndawg p00ndawg is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 8
Why does my child process not exit?

Im sure it has something to do with the wait() call, but everything ive tried either leaves me with a zombie or with the exec executing indefinitely.
Code:
switch(pid = fork())
{
case -1:perror("fork failed");
exit(1);

case 0: 
if(key == "cd")
    {
        
        execl("/bin/cd", "cd", data, (char *)0);
                
    }
    else{
        execl("/bin/sh", key, data, (char *)0);
        perror("exec failed");
        exit(status);    
        }
        
            
default:     waitpid (pid, &status, 0); 
             printf("Done: \n");
        exit(0);
         
}

Last edited by vbe; 07-03-2009 at 08:51 AM.. Reason: added code tag
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:13 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0