Update APUE ch1_fileIO source code, fix loss head file result to compile warinning on RPI bug
| | |
| | | #include <stdio.h> |
| | | #include <string.h> |
| | | #include <unistd.h> |
| | | #include <dirent.h> |
| | | #include <errno.h> |
| | | #include <sys/stat.h> |
| | | #include <sys/types.h> |
| | | #include <fcntl.h> |
| | | |
| | | |
| | | #define TEST_DIR "dir" |
| | |
| | | #include <stdio.h> |
| | | #include <errno.h> |
| | | #include <string.h> |
| | | #include <unistd.h> |
| | | #include <sys/types.h> |
| | | #include <sys/stat.h> |
| | | #include <fcntl.h> |
| | |
| | | if(fd < 0) |
| | | { |
| | | printf("Open file failure: %s\n", strerror(errno)); |
| | | return ; |
| | | return 1; |
| | | } |
| | | |
| | | dup2(fd, STDIN_FILENO); |
| | |
| | | printf("fd=%d\n", fd); |
| | | |
| | | close(fd); |
| | | |
| | | return 0; |
| | | } |
| | | |
| | |
| | | |
| | | #include <stdio.h> |
| | | #include <errno.h> |
| | | #include <unistd.h> |
| | | #include <string.h> |
| | | #include <sys/types.h> |
| | | #include <sys/stat.h> |