This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Signal handling - HELP!
- To: "'Gnu win32 mailer'" <gnu-win32 at cygnus dot com>
- Subject: Signal handling - HELP!
- From: Ian Collins <Ian at kiwiplan dot co dot nz>
- Date: Thu, 4 Sep 1997 12:40:46 +1200
HELP!
Signal handling is not functioning as expected under gnu-win32.
When a signal (e.g. SIGALRM) is triggored while in certain system calls
(e.g, read), the POSIX signal definition states that after completion of
the signal handler, the system call can be made to continue (SA_RESTART)
or to return with an error status set.
In my application, I require the read system call to RETURN after a
SIGALRM. This same code is running as required on many flavours of UNIX,
but under GNU-WIN32 (b18), the read system call ALWAYS restarts (i.e,
does not return).
Following is a small program that illustrates the problem:
#include <stdio.h>
#include <signal.h>
main()
{
extern void callme();
int c;
int tm = 2;
while (1) {
(void) fexec_signal(SIGALRM, tm, callme);
if (read(0, c, 1) >0) {
printf("Read returned %c\n", c);
}
else {
printf("Read returned negative\n");
}
alarm(0);
}
}
int fexec_signal(sig, tm, routine_name)
int sig;
int tm;
void (*routine_name)();
{
struct sigaction vec;
vec.sa_handler = routine_name;
if (sigemptyset(&vec.sa_mask) == -1) return -1;
vec.sa_flags = 0;
if (sigaction(sig, &vec, NULL) == -1) return -1;
if (sig == SIGALRM) alarm(tm);
return 0;
}
void callme()
{
printf("Timed out\n");
}
Many Regards,
Ian Collins
-
For help on using this list (especially unsubscribing), send a message
to
"gnu-win32-request@cygnus.com" with one line of text: "help".
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".