2011-05-08 1 views
1

:execl 함수, 내가, 내 유일한 내 첫 execl 함수 문은 다음 코드 실행의 인식입니다 몇 가지 이유를 들어 C 프로그래밍

pid = fork(); 
if(pid < 0){ 
    fprintf(stderr, "Fork Failed.\n"); 
    exit(1); 
    return; 
}else if(pid==0){ 
     if(execl("/home/tropix/hw11-2","/home/tropix/hw11-2",semarg,pipe_to_p3,pipe_to_p4,(char*)0)){ 
      fprintf(stderr, "File Exexecution of hw11-2 failed.\n"); 
      exit(1); 
     } 
     if(execl("/home/tropix/hw11-3","/home/tropix/hw11-3",shmarg,semarg,pipe_from_p2,pipe_to_p5_1, (char*)0)){ 
      fprintf(stderr, "File Execution of hw11-3 failed.\n"); 
      exit(1); 
     } 
     if(execl("/home/tropix/hw11-4","/home/tropix/hw11-4",shmarg,semarg,pipe_from_p2_2,pipe_to_p5_2, (char*)0)){ 
      fprintf(stderr, "File Execution of hw11-4 failed.\n"); 
      exit(1); 
     } 
     if(execl("/home/tropix/hw11-5","/home/tropix/hw11-5",semarg,pipe_from_p3,pipe_from_p4,(char*)0)){ 
      fprintf(stderr, "File Execution of hw11-5 failed.\n"); 
      exit(1); 
     } 
} else (...parent stuff...) 

는 사람에 관해서는 아이디어가 있습니까 왜 이래?

감사합니다 :)

답변

2

exec 패밀리는 사용자 프로세스를 사용자가 지정한 것과 바꾸기 때문에 성공할 경우 함수가 반환되지 않습니다.

0

exec*은 현재 프로세스 이미지를 새 프로세스 이미지로 바꾸므로 여러 어린이 프로세스를 생성하려는 경우 exec*() 번마다 fork() 번씩 필요합니다.