Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Oct 1998 18:18:55 -0700 (PDT)
From:      Archie Cobbs <archie@whistle.com>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   bug with SIGIO?
Message-ID:  <199810150118.SAA02921@bubba.whistle.com>

next in thread | raw e-mail | index | archive | help
Hi,
The program included below seems to indicate a bug with SIGIO,
in that the process is not always getting signalled when the
file descriptor is writable.

If you run this program, it outputs for a while, then stops,
then resumes when you hit return (which causes a readable condition).

I've verified this behavior in 2.2.7 but not 3.0-current.

Q1. Is this in fact a bug, or else a misunderstanding?
Q2. If this is not a bug, what is the correct way to do this?

I apologize if this is already know; didn't find anything
in the PR database.

Thanks,
-Archie

___________________________________________________________________________
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com

#include <fcntl.h>
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <errno.h>
#include <sys/ioctl.h>

void catch() { }

int
main(int ac, void *av[])
{
	sigset_t empty, block;
	int on = 1;

	fcntl(1, F_SETFL, O_NONBLOCK);
	ioctl(1, FIOASYNC, &on);

	sigemptyset(&empty);
	sigemptyset(&block);
	sigaddset(&block, SIGIO);
	sigprocmask(SIG_BLOCK, &block, NULL);
	signal(SIGIO, catch);

	for (;;) {
		int w = write(1, "!@#$%", 5);
		if (w < 0 && errno == EWOULDBLOCK) {
			sigsuspend(&empty);
			write(1, " resumed ", 7);
		}
	}
}


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810150118.SAA02921>