Go to the first, previous, next, last section, table of contents.


__djgpp_set_ctrl_c

Syntax

#include <sys/exceptn.h>

int __djgpp_set_ctrl_c(int enable);

Description

This function sets and resets the bit which controls whether signals SIGINT and SIGQUIT (see section signal) will be raised when you press the INTR or QUIT keys. By default these generate signals which, if uncaught by a signal handler, will abort your program. However, when you call the setmode library function to switch the console reads to binary mode, or open the console in binary mode for reading, this generation of signals is turned off, because some programs want to get the `^C' and `^\' characters as any other character and handle them by themselves.

__djgpp_set_ctrl_c lets you explicitly determine the effect of INTR and QUIT keys. When called with non-zero value of enable, it arranges for SIGINT and SIGQUIT signals to be generated when the appropriate key is pressed; if you call it with a zero in enable, these keys are treated as normal characters.

For getting similar effects via the POSIX termios functions, see section tcsetattr.

Note that the effect of Ctrl-BREAK key is unaffected by this function; use the _go32_want_ctrl_break library function to control it.

Also note that in DJGPP, the effect of the interrupt signal will only be seen when the program is in protected mode (See section signal, for more details). Thus, if you press Ctrl-C while your program calls DOS (e.g., when reading from the console), the SIGINT signal handler will only be called after that call returns.

Return Value

The previous state of SIGINT and SIGQUIT generation: 0 if it was disabled, 1 if it was enabled.

Portability

not ANSI, not POSIX

Example

  setmode(fileno(stdin), O_BINARY);
  if (isatty(fileno(stdin)));
    __djgpp_set_ctrl_c(1);


Go to the first, previous, next, last section, table of contents.