This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ANNOUNCEMENT] TEST: Cygwin 3.1.0-0.1

Hi Corinna,

On Fri, 9 Aug 2019 20:53:38 +0200
Corinna Vinschen <> wrote:

> Hi folks,
> I uploaded a new Cygwin test release 3.1.0-0.1
> This release comes with a couple of new features and quite a few
> bug fixes.
> The most interesting change, courtesy Ken Brown, is a revamp of the
> old FIFO code.  It should now be possible to open FIFOs multiple times
> for writing, something the old code failed on.
> Please test.

I tested this test release, and found a few problems.

(1) The cursor position is not restored correctly after screen
    alternation in the case of xterm compatible mode is enabled.
(2) fork() on console ocasionally falls into deadlock.
(3) Horizontal tab setting on console is broken after resizing
    console window if xterm compatible mode is enabled.
(4) Segmentation fault occurs in some cases regarding signalfd.

I will propose patches for (1),(2) and (3) in the other posts.

However, I can not find out the cause of problem (4). This seems
to affect only 32bit version of cygwin.

To reproduce (4), use a simple test case attached (signalfd-chk.c).
Compile it and execute, then type 'q' or '^C' to stop it.
This causes segmentation fault.

I am not sure why, but, the patch attached (signalfd-segfault.diff)
resolves the problem (4).

Could you please have a look?
#include <stdio.h>
#include <unistd.h>
#include <poll.h>
#include <termios.h>
#include <sys/signalfd.h>
#include <sys/wait.h>

int run()
	struct termios tt;
	sigset_t sigset;
	pid_t pid;
	struct pollfd pfd[2];
	int running = 1;

	tcgetattr(STDIN_FILENO, &tt);
	tt.c_lflag &= ~(ECHO|ICANON|ISIG);
	tcsetattr(STDIN_FILENO, TCSANOW, &tt);

	pid = fork();
	if (pid == 0) {
		/* Child */
		return 0;
	printf("Start: %d\n", pid);

	sigaddset(&sigset, SIGCHLD);
	sigprocmask(SIG_BLOCK, &sigset, NULL);

	pfd[0].fd = STDIN_FILENO;
	pfd[0].events = POLLIN;
	pfd[1].fd = signalfd(-1, &sigset, 0);
	pfd[1].events = POLLIN;

	do {
		poll(pfd, 2, -1);
		if (pfd[0].revents & POLLIN) {
			char c;
			int ret = read(pfd[0].fd, &c, 1);
			if (ret == 0 || c == 'q' || c == '\003') {
				running = 0;
		if (pfd[1].revents & POLLIN) {
			struct signalfd_siginfo info;
			int ret = read(pfd[1].fd, &info, sizeof(info));
			if (ret) printf("Signal: %d\r\n", info.ssi_signo);
			if (info.ssi_signo == SIGCHLD) break;
	} while (1);
	waitpid(pid, NULL, 0);
	printf("End: %d\n", pid);

	tcgetattr(STDIN_FILENO, &tt);
	tt.c_lflag |= ECHO|ICANON|ISIG;
	tcsetattr(STDIN_FILENO, TCSANOW, &tt);

	return running;

int main()
	while (run());
	return 0;

Attachment: signalfd-segfault.diff
Description: Text document

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]