getline() is repeatedly reading the file, when fork() is used
问题 I am developing a simple shell program, a command line interpreter and I wanted to read input from the file line by line, so I used getline() function. At the first time, the program works correctly, however, when it reaches the end of the file, instead of terminating, it starts to read a file from the start and it runs infinitely. Here are some codes in main function that are related to getline(): int main(int argc,char *argv[]){ int const IN_SIZE = 255; char *input = NULL; size_t len = IN