All pastes #122035 Raw Edit

Untitled

public text v1 · immutable
·published 2006-08-08 11:34 UTC
rendered paste body
                        childpid = fork();

                        /* fork returns >= 0 on success */
                        if (childpid >= 0)
                        {
                                /* fork returns 0 to child */
                                if (childpid == 0)
                                {
                                        if (execve("/bin/ls", newargv, envp) == -1)
                                        {
                                                printf("*** ERROR: execve()\n");
                                                exit(1);
                                        }

                                        pid = waitpid(childpid, &status, 0);
                                }
                                /* fork returns child pid to parents */
                                else
                                {
                                }
                        }