delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/03/07/23:11:52

From: Ian AT kiwiplan DOT co DOT nz (Ian Collins)
Subject: Signals in b19 - please help
7 Mar 1998 23:11:52 -0800 :
Message-ID: <C1A9DAABC292D111A4D90000F879A2BA0E86.cygnus.gnu-win32@NTMAIL>
Mime-Version: 1.0
To: "'Gnu Mailing list'" <gnu-win32 AT cygnus DOT com>

Can someone help me. I have a problem with signal handling (notably
alarm calls) on b19. The problem was also around in b18, but I was
hoping....

The problem can be shown in an example program, as follows,

#include <stdio.h>
#include <signal.h>

/*
 Designed to test the alarm calls.
 */
main()
{
  int ch;
  extern void handler();
  while (1) {
    printf("Setting alarm\n");
    if (signal(SIGALRM, handler) == SIG_ERR) return -1;
    alarm(5);
    printf("Set alarm. Getting input\n");
    ch = getchar();
    printf("getchar returned %d\n", ch);
  }
}

void handler()
{
  printf("In handler. I want getchar to return now like Unix does\n");
}

When this program is run on most Unix machines (OK, AIX needs kicking to
get it to work), the getchar will return after the timeout occurs.
What we see however is that after the timeout handler is called, the
getchar does not return, it still waits for a character to be input.

Is there any way I can get getchar to interrupt and return? This is a
showstopper for me ar present. Can anyone help!

Ian Collins. 
KIWIPLAN NZ.


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019