After forking and executing a child program by function execvp(), the parent process exit. However this cause the function fgets() in the child pro
execvp()
fgets()
You should check the return value from fgets() before printing buffer. Check if fgets doesnot return NULL, and then only print the buffer.