nightt5879 commented on code in PR #3511:
URL: https://github.com/apache/nuttx-apps/pull/3511#discussion_r3328141847


##########
system/popen/popen.c:
##########
@@ -45,17 +46,78 @@
  * Private Types
  ****************************************************************************/
 
-/* struct popen_file_s is a cast compatible version of FILE that contains
- * the additional PID of the shell processes needed by pclose().
- */
-
 struct popen_file_s
 {
-  FILE copy;
-  FILE *original;
+  FAR struct popen_file_s *flink;
+  FAR FILE *stream;
   pid_t shell;
 };
 
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static sem_t g_popen_sem = SEM_INITIALIZER(1);
+static FAR struct popen_file_s *g_popen_files;

Review Comment:
   Thanks for the pointer. I followed this direction and reworked the 
implementation to use fopencookie(): popen now stores the pipe fd and shell pid 
in the stream's private cookie instead of a global FILE-to-pid list. The cookie 
callbacks forward read/write/close to the fd, and pclose() retrieves the pid 
from the cookie before fclose()/waitpid(). The popen test remains in the second 
commit and passes on sim:nsh.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to