[PATCH] Cygwin: pipe: Restore non-blocking mode which was reset for non-cygwin app.
Takashi Yano
takashi.yano@nifty.ne.jp
Mon Mar 11 13:18:57 GMT 2024
On Mon, 11 Mar 2024 20:42:37 +0900
Takashi Yano wrote:
> On Mon, 11 Mar 2024 11:47:32 +0100
> Corinna Vinschen wrote:
> > 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 for the reviewing and advice. I'll work for v2 patch. Please wait a while.
I have reconsider what is essential. Then, just setting read pipe to non-blocking
mode for cygwin apps is enough when it starts.
Please review v2 patch attached.
--
Takashi Yano <takashi.yano@nifty.ne.jp>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: v2-0001-Cygwin-pipe-Make-sure-to-set-read-pipe-non-blocki.patch
URL: <https://cygwin.com/pipermail/cygwin-patches/attachments/20240311/a9a29fa1/attachment.ksh>
More information about the Cygwin-patches
mailing list