Child process cannot read after the exiting of parent process

后端 未结 2 1564
星月不相逢
星月不相逢 2020-12-19 16:27

After forking and executing a child program by function execvp(), the parent process exit. However this cause the function fgets() in the child pro

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-19 16:39

    You should check the return value from fgets() before printing buffer. Check if fgets doesnot return NULL, and then only print the buffer.

提交回复
热议问题