fcntl질문이요?
글쓴이: namola / 작성시간: 월, 2004/02/23 - 9:54오전
1 #include <sys/types.h>
2 #include <unistd.h>
3 #include <fcntl.h>
4 #include <sys/wait.h>
5 #include "myhdr.h"
6
7 int main(void)
8 {
9 pid_t pid;
10
11 /* 파일 디스크립터 플래그(close-on-exec)를 1로 설정한다 */
12 if (fcntl(STDOUT_FILENO, F_SETFD, 0) < 0)
13 syserr_exit("error at fcntl()");
14
15 switch(pid = fork())
16 {
17 case -1 :
18 /* fork()의 리턴값이 -1이면 에러 */
19 syserr_exit("error at fork()");
20 break;
21
22 case 0 :
23 /* fork()의 리턴값이 0이면 자식 프로세스 */
24 if (execl("/bin/ls", "ls", "-la", (char *) 0) < 0)
25 syserr_exit("error at execl()");
26
27 break;
28
29 default :
30 /* 부모 프로세스의 리턴값은 자식 프로세스의 PID */
31 if (wait(NULL) < 0)
32 syserr_exit("error at wait()");
33 break;
34 }
35
36 return;
37 }다음과 같이 하면...ls -al 명령어가 실행되는데...
fcntl(STDOUT_FILENO, F_SETFD, 1) 0에서 1로 바꾸면...ls -al 명령어가
실행이 안되는거지요?
Forums:


다음을 참고하세요...http://www.joinc.co.kr/m
다음을 참고하세요...
http://www.joinc.co.kr/modules.php?name=News&file=article&sid=93
댓글 달기