All pastes #389951 Raw Edit

Mine

public c v1 · immutable
·published 2007-03-11 01:55 UTC
rendered paste body
                else if(piping == TRUE)                {                        processID = fork();                        if(processID == -1) //Error                        {                                perror("first fork error");                                exit(1);                        }                        else if(processID == 0) //Child process                        {                                if(pipe(filedes) != -1)                                {                                        processID = fork();                                        if (processID == -1) //pipe() failed                                        {                                                perror("second fork error");                                                exit(1);                                        }                                        else if(processID == 0) //Child process                                        {                                                if(close(STDOUT) == -1)                                                        perror("");                                                if(dup(filedes[STDOUT]) == -1)                                                        perror("");                                                if(close(filedes[STDIN]) == -1)                                                        perror("");                                                ret = execvp(command_1[0], command_1);                                                if(ret != 0)                                                        perror("exec hath failt");                                                exit(1);                                        }                                        else //Parent process                                        {                                                if(close(STDIN) == -1)                                                        perror("PROGRAM 2");                                                if(dup(filedes[STDIN]) == -1)                                                        perror("PROGRAM 2");                                                if(close(filedes[STDOUT]))                                                        perror("PROGRAM 2");                                                ret = execvp(command_2[0], command_2);                                                if(ret != 0)                                                        perror("exec hath failt");                                                exit(1);                                        }                                }                        }                        waitpid(processID, &stat, 0); //This finally fixed the !@# enter bug. /sebbz                }