test_fcntl.c
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:1k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. #include <stdio.h>
  2. #include <fcntl.h>
  3. main()
  4. {
  5. int flags, child;
  6. if ((flags = fcntl(0, F_GETFL)) < 0) {
  7. perror("fcntl 1st GETFL");
  8. }
  9. printf ("flags = %xn", flags);
  10. switch(child = fork()) {
  11. case -1:
  12. printf("error during forkn");
  13. break;
  14. case 0: /* child */
  15. execlp("test_create", "test_create", NULL);
  16. break;
  17. default: /* parent */
  18. wait(NULL);
  19. break;
  20. }
  21. while(1){
  22. if ((flags = fcntl(0, F_GETFL)) < 0) {
  23. perror("fcntl parent GETFL");
  24. }
  25. printf ("parent %d flags = %xn", child, flags);
  26. sleep(1);
  27. }
  28. }