On Wed, 25 Jun 2025 20:51:02 +0900
Takashi Yano wrote:
> On Wed, 25 Jun 2025 19:55:34 +0900
> Takashi Yano wrote:
> > Hi Johannes,
> > 
> > On Wed, 25 Jun 2025 09:38:17 +0200 (CEST)
> > Johannes Schindelin wrote:
> > > Hi Takashi,
> > > 
> > > On Wed, 25 Jun 2025, Johannes Schindelin wrote:
> > > 
> > > > On Wed, 25 Jun 2025, Takashi Yano wrote:
> > > > 
> > > > > I'd revise the patch as follows. Could you please test if the
> > > > > following patch also solves the issue?
> > > > 
> > > > Will do.
> > > 
> > > For the record, in my tests, this fixed the hangs, too.
> > 
> > Thanks for testing.
> > However, I noticed that this patch changes the behavior Corinna was
> > concerned about.
> 
> The behaviour change can be checked using attached test case.

Hmm, then, nga888(Andrew Ng @github)'s solution seems to be
the best one.
https://github.com/git-for-windows/git/issues/5688#issuecomment-2995952882

The test result of the attached STC is the same as that of cygwin 3.6.3.

-- 
Takashi Yano <[email protected]>
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
#include <fcntl.h>

#define PIPE_SIZE 65536

int main()
{
	int fd[2];
	char buf[PIPE_SIZE];
	int flags;

	pipe(fd);

	/* Set non-blocking */
	flags = fcntl(fd[1], F_GETFL);
	flags |= O_NONBLOCK;
	fcntl(fd[1], F_SETFL, flags);

	/* Fill pipe */
	printf("w:%d\n", write(fd[1], buf, PIPE_SIZE));
	/* Free PIPE_BUF/2 bytes */
	printf("r:%d\n", read(fd[0], buf, PIPE_BUF/2));

	/* Write PIPE_BUF bytes */
	printf("w:%d\n", write(fd[1], buf, 1));
	printf("w:%d\n", write(fd[1], buf, PIPE_BUF-1));
	printf("w:%d\n", write(fd[1], buf, PIPE_BUF));
	printf("w:%d\n", write(fd[1], buf, PIPE_BUF+1));
	printf("w:%d\n", write(fd[1], buf, PIPE_BUF*2));
	printf("w:%d\n", write(fd[1], buf, PIPE_BUF*2));
	printf("w:%d\n", write(fd[1], buf, PIPE_BUF*2));
	printf("w:%d\n", write(fd[1], buf, PIPE_BUF*2));
	printf("w:%d\n", write(fd[1], buf, PIPE_BUF*2));
	printf("w:%d\n", write(fd[1], buf, PIPE_BUF*2));
	printf("w:%d\n", write(fd[1], buf, PIPE_BUF*2));
	printf("w:%d\n", write(fd[1], buf, PIPE_BUF*2));
	printf("w:%d\n", write(fd[1], buf, PIPE_BUF*2));
	printf("w:%d\n", write(fd[1], buf, PIPE_BUF*2));

	return 0;
}

Reply via email to