=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/signal.c,v retrieving revision 1.1.1.3 retrieving revision 1.1.1.4 diff -u -r1.1.1.3 -r1.1.1.4 --- src/usr.bin/less/signal.c 2011/09/16 17:47:08 1.1.1.3 +++ src/usr.bin/less/signal.c 2014/04/25 13:33:51 1.1.1.4 @@ -1,11 +1,10 @@ /* - * Copyright (C) 1984-2011 Mark Nudelman + * Copyright (C) 1984-2012 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * - * For more information about less, or for information on how to - * contact the author, see the README file. + * For more information, see the README file. */ @@ -15,8 +14,6 @@ * 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 * 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" @@ -25,14 +22,13 @@ /* * "sigs" contains bits indicating signals which need to be processed. */ -public int sigs; +public volatile sig_atomic_t sigs; extern int sc_width, sc_height; extern int screen_trashed; extern int lnloop; extern int linenums; extern int wscroll; -extern int reading; extern int quit_on_intr; extern long jump_sline_fraction; @@ -44,11 +40,9 @@ u_interrupt(type) int type; { - bell(); #if OS2 LSIGNAL(SIGINT, SIG_ACK); #endif - LSIGNAL(SIGINT, u_interrupt); sigs |= S_INTERRUPT; #if MSDOS_COMPILER==DJGPPC /* @@ -59,8 +53,6 @@ if (kbhit()) getkey(); #endif - if (reading) - intread(); /* May longjmp */ } #ifdef SIGTSTP @@ -72,10 +64,7 @@ stop(type) int type; { - LSIGNAL(SIGTSTP, stop); sigs |= S_STOP; - if (reading) - intread(); } #endif @@ -88,10 +77,7 @@ winch(type) int type; { - LSIGNAL(SIGWINCH, winch); sigs |= S_WINCH; - if (reading) - intread(); } #else #ifdef SIGWIND @@ -103,10 +89,7 @@ winch(type) int type; { - LSIGNAL(SIGWIND, winch); sigs |= S_WINCH; - if (reading) - intread(); } #endif #endif @@ -251,7 +234,26 @@ #endif if (tsignals & S_INTERRUPT) { + bell(); if (quit_on_intr) quit(QUIT_INTERRUPT); } +} + +/* + * 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); }