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


##########
system/popen/popen.c:
##########
@@ -397,17 +425,20 @@ FILE *popen(FAR const char *command, FAR const char *mode)
 
 errout_with_stream:
   fclose(stream);
-  container = NULL;
+  close(newfd[0]);

Review Comment:
   fclose will close newfd for us?



##########
system/popen/popen.c:
##########
@@ -97,11 +97,37 @@ static off_t popen_file_seek(FAR void *cookie, FAR off_t 
*offset,
 static int popen_file_close(FAR void *cookie)
 {
   FAR struct popen_file_s *filep = (FAR struct popen_file_s *)cookie;
+  int errcode = OK;
   int ret;
+#ifdef CONFIG_SCHED_WAITPID
+  int status;
+#endif
 
   ret = close(filep->fd);
+  if (ret < 0)
+    {
+      errcode = errno;
+    }
+
+#ifdef CONFIG_SCHED_WAITPID
+  if (filep->shell > 0)
+    {
+      ret = waitpid(filep->shell, &status, 0);
+      if (ret < 0 && errcode == OK)
+        {
+          errcode = errno;
+        }
+    }
+#endif
+
   free(filep);
-  return ret;
+  if (errcode != OK)
+    {
+      errno = errcode;

Review Comment:
   why need set errno manually?



-- 
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