test_fcntl.c
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:1k
- #include <stdio.h>
- #include <fcntl.h>
- main()
- {
- int flags, child;
- if ((flags = fcntl(0, F_GETFL)) < 0) {
- perror("fcntl 1st GETFL");
- }
- printf ("flags = %xn", flags);
- switch(child = fork()) {
- case -1:
- printf("error during forkn");
- break;
- case 0: /* child */
- execlp("test_create", "test_create", NULL);
- break;
- default: /* parent */
- wait(NULL);
- break;
- }
-
- while(1){
- if ((flags = fcntl(0, F_GETFL)) < 0) {
- perror("fcntl parent GETFL");
- }
- printf ("parent %d flags = %xn", child, flags);
- sleep(1);
- }
- }