[PATCH] Cygwin: pipe: Restore non-blocking mode which was reset for non-cygwin app.

Corinna Vinschen corinna-cygwin@cygwin.com
Mon Mar 11 10:47:32 GMT 2024


Hi Takashi,

On Mar 10 19:31, Takashi Yano wrote:
> @@ -590,6 +591,10 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
>  	      {
>  		fhandler_pipe *pipe = (fhandler_pipe *)(fhandler_base *) cfd;
>  		pipe->set_pipe_non_blocking (false);
> +		pipew_duped = (fhandler_pipe *)
> +			ccalloc (HEAP_FHANDLER, 1, sizeof (fhandler_pipe));
> +		pipew_duped = new (pipew_duped) fhandler_pipe;
> +		pipe->dup (pipew_duped, 0);
>  		if (pipe->request_close_query_hdl ())
>  		  need_send_sig = true;
>  	      }

The code setting up pipes and the dummy_tty is sufficiently complex,
so that I wonder if it shouldn't have

- its own methods and
- comments to describe why this stuff is necessary.

What about adding two methods, kind of like (the names are only
suggestion, albeit bad ones):

  child_info_spawn::noncygwin_child_pre_fork()

to keep the above stuff together (plus comments) and

  child_info_spawn::noncygwin_child_post_fork()

for the below code?

> @@ -597,6 +602,10 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
>  	      {
>  		fhandler_pipe *pipe = (fhandler_pipe *)(fhandler_base *) cfd;
>  		pipe->set_pipe_non_blocking (false);
> +		piper_duped = (fhandler_pipe *)
> +			ccalloc (HEAP_FHANDLER, 1, sizeof (fhandler_pipe));
> +		piper_duped = new (piper_duped) fhandler_pipe;
> +		pipe->dup (piper_duped, 0);
>  	      }
>  
>  	  if (need_send_sig)
> @@ -905,6 +914,19 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
>  	      term_spawn_worker.cleanup ();
>  	      term_spawn_worker.close_handle_set ();
>  	    }
> +	  if (pipew_duped)
> +	    {
> +	      bool is_nonblocking = pipew_duped->is_nonblocking ();
> +	      pipew_duped->set_pipe_non_blocking (is_nonblocking);

Is that really right?  You're asking pipew_duped for its
nonblocking flag and then set pipew_duped to the same value...?

> +	      pipew_duped->close ();
> +	      cfree (pipew_duped);
> +	    }


Thanks,
Corinna


More information about the Cygwin-patches mailing list