[PATCH] Cygwin: pipe: Restore blocking mode of read pipe on close()

Takashi Yano takashi.yano@nifty.ne.jp
Mon Sep 2 11:49:28 GMT 2024


On Mon, 2 Sep 2024 13:10:31 +0200
Corinna Vinschen wrote:
> On Aug 30 23:15, Takashi Yano wrote:
> > If a cygwin app is executed from a non-cygwin app and the cygwin
> > app exits, read pipe remains on non-blocking mode because of the
> > commit fc691d0246b9. Due to this behaviour, the non-cygwin app
> > cannot read the pipe correctly after that. With this patch, the
> > blocking mode of the read pipe is stored into was_blocking_read_pipe
> > on set_pipe_non_blocking() when the cygwin app starts and restored
> > on close().
> 
> Looks ok to me, but it would be helpful if Johannes could test this as
> well.
> 
> I just wonder if the whole code could be simplified, if we set
> the pipe to non-blocking only temporarily while reading or writing,
> while the pipe is blocking all the time otherwise:
> 
> - Create pipe blocking
> 
> - set_pipe_non_blocking(true);
>   NtReadFile() or NtWriteFile();
>   set_pipe_non_blocking(false)
> 
> How costly is it to call NtSetInformationFile(FilePipeInformation)
> for each read/write?

Good point. I'll try performance test for that idea.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>


More information about the Cygwin-patches mailing list