version 1.6, 2003/04/13 18:26:26 |
version 1.7, 2003/06/07 03:35:19 |
|
|
|
|
#include "less.h" |
#include "less.h" |
#include <signal.h> |
#include <signal.h> |
#include <setjmp.h> |
|
#if HAVE_TIME_H |
#if HAVE_TIME_H |
#include <time.h> |
#include <time.h> |
#endif |
#endif |
|
|
#define time_type long |
#define time_type long |
#endif |
#endif |
|
|
/* |
|
* BSD setjmp() saves (and longjmp() restores) the signal mask. |
|
* This costs a system call or two per setjmp(), so if possible we clear the |
|
* signal mask with sigsetmask(), and use _setjmp()/_longjmp() instead. |
|
* On other systems, setjmp() doesn't affect the signal mask and so |
|
* _setjmp() does not exist; we just use setjmp(). |
|
*/ |
|
#if HAVE__SETJMP && HAVE_SIGSETMASK |
|
#define SET_JUMP _setjmp |
|
#define LONG_JUMP _longjmp |
|
#else |
|
#define SET_JUMP setjmp |
|
#define LONG_JUMP longjmp |
|
#endif |
|
|
|
public int reading; |
|
|
|
static jmp_buf read_label; |
|
|
|
extern int sigs; |
extern int sigs; |
|
|
/* |
/* |
* Like read() system call, but is deliberately interruptible. |
* Like read() system call, but is deliberately interruptible. |
* A call to intread() from a signal handler will interrupt |
|
* any pending iread(). |
|
*/ |
*/ |
public int |
public int |
iread(fd, buf, len) |
iread(fd, buf, len) |
|
|
} |
} |
#endif |
#endif |
#endif |
#endif |
if (SET_JUMP(read_label)) |
|
{ |
|
/* |
|
* We jumped here from intread. |
|
*/ |
|
reading = 0; |
|
#if HAVE_SIGPROCMASK |
|
{ |
|
sigset_t mask; |
|
sigemptyset(&mask); |
|
sigprocmask(SIG_SETMASK, &mask, NULL); |
|
} |
|
#else |
|
#if HAVE_SIGSETMASK |
|
sigsetmask(0); |
|
#else |
|
#ifdef _OSK |
|
sigmask(~0); |
|
#endif |
|
#endif |
|
#endif |
|
return (READ_INTR); |
|
} |
|
|
|
flush(); |
flush(); |
reading = 1; |
|
#if MSDOS_COMPILER==DJGPPC |
#if MSDOS_COMPILER==DJGPPC |
if (isatty(fd)) |
if (isatty(fd)) |
{ |
{ |
|
|
} |
} |
} |
} |
#endif |
#endif |
reading = 0; |
|
if (n < 0) |
if (n < 0) |
return (-1); |
return (errno == EINTR ? READ_INTR : -1); |
return (n); |
return (n); |
} |
|
|
|
/* |
|
* Interrupt a pending iread(). |
|
*/ |
|
public void |
|
intread() |
|
{ |
|
LONG_JUMP(read_label, 1); |
|
} |
} |
|
|
/* |
/* |