The file position was affected by child process. The following sample does not work fine. But this code works fine on Solaris. [CODE] #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #define READ_SIZE 256 #define ERR -1 main(int argc, char *argv[], char *envp[]) { int pid; int rc; int status; FILE *fd; char data_rec[READ_SIZE + 1]; if(argc != 2){ fprintf(stderr, "Usage: %s file_name\n", argv[0]); exit(-1); } printf("Main_First\n"); if((fd = fopen(argv[1], "r")) == 0) { perror(argv[0]); fprintf(stderr, "%s: fopen() for \"%s\" failed.\n", argv[0], argv[1]); exit(ERR); } pid = fork(); if (pid == -1) { perror(argv[0]); fprintf(stderr, "%s: fork error.\n", argv[0]); exit(errno); } else if (pid == 0) { printf("Child_First\n"); if(fgets(data_rec, READ_SIZE, fd) != NULL) { fprintf(stdout, "Read data: %s\n", data_rec); } else { perror("fgets()"); fprintf(stderr, "%s: c-fgets() for \"%s\" failed.\n%d\n", argv[0], argv[1], errno); exit(errno); } exit(0); } else { wait(&status); printf("Main_End\n"); if(fgets(data_rec, READ_SIZE, fd) != NULL) { fprintf(stdout, "Read data: %s\n", data_rec); } else { perror("fgets()"); fprintf(stderr, "%s: p-fgets() for \"%s\" failed.\n%d\n", argv[0], argv[1], errno); exit(errno); } exit(0); } } [HOW TO REPRODUCE] 1. make a sample data file. the following is a sample data file "data". test data line #1 test data line #2 test data line #3 test data line #4 test data line #5 2. compile the source code and execute it. $ cc test.c. $ ./a.out data Main_First Child_First Read data: test data line #1 Main_End fgets(): Success ./a.out: p-fgets() for "data" failed. 0