]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: pipe: Suppress unnecessary set_pipe_non_blocking() call.
authorTakashi Yano <takashi.yano@nifty.ne.jp>
Wed, 17 Nov 2021 03:39:04 +0000 (12:39 +0900)
committerTakashi Yano <takashi.yano@nifty.ne.jp>
Wed, 17 Nov 2021 17:58:54 +0000 (02:58 +0900)
- Call set_pipe_non_blocking(false) only if the pipe will be really
  inherited to non-cygwin process.

winsup/cygwin/spawn.cc

index 6b2026776578e45cae3b8c467b8e79227842888e..e160fa3bb592c8fb9e40cda8a6b4a714a74f9977 100644 (file)
@@ -648,8 +648,9 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
 
       if (!iscygwin ())
        {
+         int fd;
          cfd.rewind ();
-         while (cfd.next () >= 0)
+         while ((fd = cfd.next ()) >= 0)
            if (cfd->get_major () == DEV_PTYS_MAJOR)
              {
                fhandler_pty_slave *ptys =
@@ -657,13 +658,15 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
                ptys->create_invisible_console ();
                ptys->setup_locale ();
              }
-           else if (cfd->get_dev () == FH_PIPEW)
+           else if (cfd->get_dev () == FH_PIPEW
+                    && (fd == (in__stdout < 0 ? 1 : in__stdout) || fd == 2))
              {
                fhandler_pipe *pipe = (fhandler_pipe *)(fhandler_base *) cfd;
                pipe->close_query_handle ();
                pipe->set_pipe_non_blocking (false);
              }
-           else if (cfd->get_dev () == FH_PIPER)
+           else if (cfd->get_dev () == FH_PIPER
+                    && fd == (in__stdin < 0 ? 0 : in__stdin))
              {
                fhandler_pipe *pipe = (fhandler_pipe *)(fhandler_base *) cfd;
                pipe->set_pipe_non_blocking (false);
This page took 0.034482 seconds and 5 git commands to generate.