1) Fix longstanding bug:

trap 'echo xxx' 1 2 3 15
	read x
is not interrupted by ^C (due to restartable read syscall) and must be
interrupted per POSIX
Worse case:
	read -t 5 x
hangs forever after ^C pressed (supposed to timeout after 5 secs)
Fixed by adding siginterrupt(signo, 1) after catch handler installed

2) Do not reinstall sighandler immediately after it is called,
BSD do it for us
This commit is contained in:
Andrey A. Chernov 1997-11-05 23:33:58 +00:00
parent b113690ced
commit 8dd81503df

View File

@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: trap.c,v 1.8 1997/02/22 13:58:46 peter Exp $
*/
#ifndef lint
@ -212,6 +212,7 @@ setsignal(signo)
int action;
sig_t sigact = SIG_DFL;
char *t;
long sig;
if ((t = trap[signo]) == NULL)
action = S_DFL;
@ -280,7 +281,12 @@ setsignal(signo)
case S_IGN: sigact = SIG_IGN; break;
}
*t = action;
return (long)signal(signo, sigact);
sig = (long)signal(signo, sigact);
#ifdef BSD
if (sig != -1 && action == S_CATCH)
sig = siginterrupt(signo, 1);
#endif
return sig;
}
@ -339,8 +345,9 @@ void
onsig(signo)
int signo;
{
#ifndef BSD
signal(signo, onsig);
#endif
if (signo == SIGINT && trap[SIGINT] == NULL) {
onint();
return;