pclose

Why does pclose return prematurely?

对着背影说爱祢 提交于 2020-07-09 17:13:43
问题 UPDATE 1: This question has been updated to eliminate the multithreading, simplifying its scope. The original problem popen ed in the main thread, and pclose d the child process in a different thread. The problem being asked about is reproducible much more simply, by doing the popen and pclose in the same (main) thread. Update 2: With help from responders at How to check libc version?, I think I've identified that the libc being used is uClibc 0.9.30. The following code popen s a script in

Why does pclose return prematurely?

拥有回忆 提交于 2020-07-09 17:13:42
问题 UPDATE 1: This question has been updated to eliminate the multithreading, simplifying its scope. The original problem popen ed in the main thread, and pclose d the child process in a different thread. The problem being asked about is reproducible much more simply, by doing the popen and pclose in the same (main) thread. Update 2: With help from responders at How to check libc version?, I think I've identified that the libc being used is uClibc 0.9.30. The following code popen s a script in

use fclose to pipe of popen is a serious bug?

一笑奈何 提交于 2019-12-23 09:07:13
问题 Some months ago I write a CGI application for Linux that uses popen() to read the output of a command, and then I close the pipe with fclose() . Now, I read that for close pipes is needs use pclose() . The manual says: The return value from popen() is a normal standard I/O stream in all respects save that it must be closed with pclose() rather than fclose(3) . My code is like this: if ((NULL != (f = popen(command.value, "r")))) { //do something fclose(f); } My question is: My mistake have a