#include <stdio.h>

#include <unistd.h>

int main()

{

        pid_t  pid;

        /* fork another process */

        pid = fork();

        if (pid < 0) { /* error occurred */

        fprintf(stderr, "Fork Failed");

        exit(-1);

        }


        else if (pid == 0) { /* child process */

        printf("Child Process is running\n");

        execlp("/bin/ls", "ls", NULL);

        sleep (10);

        printf("Child Process Complete\n");

        }

        else { /* parent process */

        /* parent will wait for the child to complete */

        wait (NULL);

        printf ("Parent Complete\n");

        exit(0);

        }

}


자식 프로세스에서 ls 호출해서 ls 명령어 수행하고 10초 기다렸다가 Chile Process Complete 출력하고


부모 프로세스로 넘어가서 Parent Complete 출력하는거 아니야?


왜 자꾸 ls 보여주고 난다음에 바로 부모프로세스로 넘어가지??


내 우분투가 이상한가???