www.delorie.com/djgpp/doc/libc/libc_142.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

__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 a non-zero, positive 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. If enable is negative, __djgpp_set_ctrl_c returns the current state of the signal generation, but doesn't change it.

For getting similar effects via the POSIX termios functions, see 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 Mechanism, 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 state of SIGINT and SIGQUIT generation before the call: 0 if it was disabled, 1 if it was enabled. If the argument enable is negative, the state is not altered.

Portability

ANSI/ISO C No
POSIX No

Example

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


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2004   by DJ Delorie     Updated Apr 2004