strange behaviour of SIG_IGN

Bernhard Weinelt weinelt at sbsvax.cs.uni-sb.de
Fri Feb 23 08:44:41 AEST 1990


Hello folks, I have a new interesting (at least for me) question:

Suppose the following little program:

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

main()
{
  int c;
  system("stty -echo cbreak");
  /*signal(SIGSEGV,SIG_IGN);*/
  while ((c=getchar())!=4) printf("%c",c);
  system("stty echo -cbreak");
}

With the signal in comments, the program works as expected:
it echo's all characters and exits on ^D.

But with the signal statement in the program, after pressing
^D there is no more reaction at the terminal and in fact
the program has spawn a new sh-process, which is indefinitly
running. A very costly behaviour on our ULTRIX and BSD4.3
VAX's.

[With SunOS the above program works fine with the signal 
statement.]

Exchanging SIG_IGN by an empty function also fixes the
problem. But can anybody explain this strange behaviour?
Thanks in advance.

Bernhard
-- 
                                         ------------------------------------
                  __________________     | Bernhard Weinelt                 |
         (__)    /                  \    | Universitaet des Saarlandes      |
         (oo)   (    Many Greetings  )   | FB 10 - Informatik (Dept. of CS) |
  /-------\/  --'\__________________/    | Bau 36, Im Stadtwald 15          |
 / |     ||                              | D-6600 Saarbruecken 11, W-Germany|
*  ||----||                              | weinelt at cs.uni-sb.de             |
   ~~    ~~                              ------------------------------------



More information about the Comp.unix.questions mailing list