version 1.4, 2003/04/13 18:26:26 |
version 1.5, 2003/06/07 03:35:19 |
|
|
* A signal usually merely causes a bit to be set in the "signals" word. |
* A signal usually merely causes a bit to be set in the "signals" word. |
* At some convenient time, the mainline code checks to see if any |
* At some convenient time, the mainline code checks to see if any |
* signals need processing by calling psignal(). |
* signals need processing by calling psignal(). |
* If we happen to be reading from a file [in iread()] at the time |
|
* the signal is received, we call intread to interrupt the iread. |
|
*/ |
*/ |
|
|
#include "less.h" |
#include "less.h" |
|
|
extern int lnloop; |
extern int lnloop; |
extern int linenums; |
extern int linenums; |
extern int wscroll; |
extern int wscroll; |
extern int reading; |
|
|
|
/* |
/* |
* Interrupt signal handler. |
* Interrupt signal handler. |
|
|
#if OS2 |
#if OS2 |
LSIGNAL(SIGINT, SIG_ACK); |
LSIGNAL(SIGINT, SIG_ACK); |
#endif |
#endif |
LSIGNAL(SIGINT, u_interrupt); |
|
sigs |= S_INTERRUPT; |
sigs |= S_INTERRUPT; |
#if MSDOS_COMPILER==DJGPPC |
#if MSDOS_COMPILER==DJGPPC |
/* |
/* |
|
|
if (kbhit()) |
if (kbhit()) |
getkey(); |
getkey(); |
#endif |
#endif |
if (reading) |
|
intread(); |
|
} |
} |
|
|
#ifdef SIGTSTP |
#ifdef SIGTSTP |
|
|
stop(type) |
stop(type) |
int type; |
int type; |
{ |
{ |
LSIGNAL(SIGTSTP, stop); |
|
sigs |= S_STOP; |
sigs |= S_STOP; |
if (reading) |
|
intread(); |
|
} |
} |
#endif |
#endif |
|
|
|
|
winch(type) |
winch(type) |
int type; |
int type; |
{ |
{ |
LSIGNAL(SIGWINCH, winch); |
|
sigs |= S_WINCH; |
sigs |= S_WINCH; |
if (reading) |
|
intread(); |
|
} |
} |
#else |
#else |
#ifdef SIGWIND |
#ifdef SIGWIND |
|
|
winch(type) |
winch(type) |
int type; |
int type; |
{ |
{ |
LSIGNAL(SIGWIND, winch); |
|
sigs |= S_WINCH; |
sigs |= S_WINCH; |
if (reading) |
|
intread(); |
|
} |
} |
#endif |
#endif |
#endif |
#endif |
|
|
} |
} |
|
|
} |
} |
|
} |
|
|
|
/* |
|
* Custom version of signal() that causes syscalls to be interrupted. |
|
*/ |
|
public void |
|
(*lsignal(s, a))() |
|
int s; |
|
void (*a) (); |
|
{ |
|
struct sigaction sa, osa; |
|
|
|
sa.sa_handler = a; |
|
sigemptyset(&sa.sa_mask); |
|
sa.sa_flags = 0; /* don't restart system calls */ |
|
if (sigaction(s, &sa, &osa) != 0) |
|
return (SIG_ERR); |
|
return (osa.sa_handler); |
} |
} |