[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[MiNT] read() and signals
Alan Hourihane wrote:
The Ctrl+C keystroke requires to press Enter to do its job, it may be related.
Alan, by chance, have you investigated this issue ?
I've seen the same problem, but not investigated yet.
I had a look at it, and I think I have found the cause of the bash problem.
Basically, the read() function should fail with EINTR when a signal is
caught, but in MiNT it continues blocking.
The attached program is a very simple testcase.
On Linux and Cygwin, I get:
$ ./mysig
Please type ^C
^CSIGINT!
ret = -1, errno = 4, msg = Interrupted system call
But on MiNT, I can type ^C several times, it does not exit:
$ ./mysig
Please type ^C
SIGINT!
SIGINT!
SIGINT!
SIGINT!
However it exits if I type a standard key, of course.
I don't know if the problem comes from the kernel or the MiNTLib.
--
Vincent Rivière
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
void myhandler(int sig)
{
puts("SIGINT!");
}
int main(void)
{
struct sigaction act, oact;
int ret;
unsigned char c;
act.sa_handler = myhandler;
act.sa_flags = 0;
sigemptyset (&act.sa_mask);
sigemptyset (&oact.sa_mask);
sigaction (SIGINT, &act, &oact);
puts("Please type ^C");
errno = 0;
ret = read (0, &c, sizeof c);
printf("ret = %d, errno = %d, msg = %s\n", ret, errno, strerror(errno));
return 0;
}