Watt-32 tcp/ip  2.2 dev-rel.10
Functions | Variables
pc_cbrk.c File Reference

Go to the source code of this file.


pragma Alias (_mwstack_limit,"_mwstack_limit")
void MS_CDECL sig_handler_watt (int sig)
 SIGINT/SIGBREAK handler function. More...
int set_cbreak (int want_brk)
 Sets normal and extended BREAK mode. More...
static BOOL WINAPI console_handler (DWORD event)
int W32_CALL tcp_cbreak (int mode)
 Sets our break mode. More...
BOOL tcp_cbreak_off (void)
void usage (char *argv0)
int main (int argc, char **argv)


UINT _mwstack_limit [2]
WORD _watt_handle_cbreak = 0
 Turn off stack-checking here because stack may be out of bounds. More...
volatile int _watt_cbroke = 0
static int cbreak_mode
static jmp_buf sig_jmp
int old_brk = -1

Detailed Description

Ctrl-C, Ctrl-Break handling.

Definition in file pc_cbrk.c.

Function Documentation

int set_cbreak ( int  want_brk)

Sets normal and extended BREAK mode.

  • want_brk 0x0000: no ^BREAK checking.
  • want_brk 0x0001: normal ^BREAK checks.
  • want_brk 0x0101: extended ^BREAK checks.
Return values
normalBREAK state in LSB, extended BREAK state in MSB.

Definition at line 129 of file pc_cbrk.c.

void MS_CDECL sig_handler_watt ( int  sig)

SIGINT/SIGBREAK handler function.

The Windows runtime docs at http://msdn.microsoft.com/library/en-us/vclib/html/_crt_signal.asp specifically forbid a number of things being done from a signal handler, including IO, memory allocation and system calls, and only allow jmpbuf if you are handling SIGFPE.

Hence sig_handler_watt() on Win32 simply increments the '_watt_cbroke' variable.

Also note the behaviour of Windows with SIGINT, which says this: Note SIGINT is not supported for any Win32 application, including Windows 98/Me and Windows NT/2000/XP. When a CTRL+C interrupt occurs, Win32 operating systems generate a new thread to specifically handle that interrupt. This can cause a single-thread application such as UNIX, to become multithreaded, resulting in unexpected behavior.

So a longjmp() from handler-thread to main-thread is out of the question.

Definition at line 73 of file pc_cbrk.c.

References _watt_cbroke, _watt_handle_cbreak, and set_cbreak().

int W32_CALL tcp_cbreak ( int  mode)

Sets our break mode.

  • `mode' is composed of the following flags
    • 0x01: disallow breakouts
    • 0x10: display a message upon ^C/^BREAK (default)

Definition at line 207 of file pc_cbrk.c.

References set_cbreak(), sig_handler_watt(), sock_sig_exit(), and win32_dos_box.

Variable Documentation

volatile int _watt_cbroke = 0

increment on SIGINT catch

Definition at line 47 of file pc_cbrk.c.

WORD _watt_handle_cbreak = 0

Turn off stack-checking here because stack may be out of bounds.

longjmp() hopefully fixes that.changes operation of the break stuff

Definition at line 46 of file pc_cbrk.c.