X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/9bf656f54a71465a017d2f2ebbb6e32f7048a9fc..e0c897d03d05e34f8e84a6b34a74bfd798591864:/usr/src/usr.bin/more/signal.c diff --git a/usr/src/usr.bin/more/signal.c b/usr/src/usr.bin/more/signal.c index 290a122728..2cd56bfd29 100644 --- a/usr/src/usr.bin/more/signal.c +++ b/usr/src/usr.bin/more/signal.c @@ -3,15 +3,13 @@ * Copyright (c) 1988 Regents of the University of California. * All rights reserved. * - * This code is derived from software contributed to Berkeley by - * Mark Nudleman. - * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the + * by Mark Nudleman and the University of California, Berkeley. The + * name of Mark Nudleman or the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR @@ -20,7 +18,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)signal.c 5.3 (Berkeley) %G%"; +static char sccsid[] = "@(#)signal.c 5.6 (Berkeley) %G%"; #endif /* not lint */ /* @@ -33,13 +31,13 @@ static char sccsid[] = "@(#)signal.c 5.3 (Berkeley) %G%"; * the signal is received, we call intread to interrupt the iread. */ -#include "less.h" +#include #include /* * "sigs" contains bits indicating signals which need to be processed. */ -public int sigs; +int sigs; #ifdef SIGTSTP #define S_STOP 02 @@ -59,10 +57,10 @@ extern int reading; /* * "Stop" (^Z) signal handler. */ - static HANDLER +static stop() { - (void) signal(SIGTSTP, stop); + (void)signal(SIGTSTP, stop); sigs |= S_STOP; if (reading) intread(); @@ -73,10 +71,9 @@ stop() /* * "Window" change handler */ - public HANDLER winch() { - signal(SIGWINCH, winch); + (void)signal(SIGWINCH, winch); sigs |= S_WINCH; if (reading) intread(); @@ -86,10 +83,9 @@ winch() /* * "Window" change handler */ - public HANDLER winch() { - signal(SIGWIND, winch); + (void)signal(SIGWIND, winch); sigs |= S_WINCH; if (reading) intread(); @@ -97,27 +93,36 @@ winch() #endif #endif +static int +purgeandquit() +{ + + purge(); /* purge buffered output */ + quit(); +} + /* * Set up the signal handlers. */ - public void init_signals(on) int on; { + int quit(); + if (on) { /* * Set signal handlers. */ - (void) signal(SIGINT, quit); + (void)signal(SIGINT, purgeandquit); #ifdef SIGTSTP - (void) signal(SIGTSTP, stop); + (void)signal(SIGTSTP, stop); #endif #ifdef SIGWINCH - (void) signal(SIGWINCH, winch); + (void)signal(SIGWINCH, winch); #else #ifdef SIGWIND - (void) signal(SIGWIND, winch); + (void)signal(SIGWIND, winch); #endif #endif } else @@ -125,15 +130,15 @@ init_signals(on) /* * Restore signals to defaults. */ - (void) signal(SIGINT, SIG_DFL); + (void)signal(SIGINT, SIG_DFL); #ifdef SIGTSTP - (void) signal(SIGTSTP, SIG_DFL); + (void)signal(SIGTSTP, SIG_DFL); #endif #ifdef SIGWINCH - (void) signal(SIGWINCH, SIG_IGN); + (void)signal(SIGWINCH, SIG_IGN); #endif #ifdef SIGWIND - (void) signal(SIGWIND, SIG_IGN); + (void)signal(SIGWIND, SIG_IGN); #endif } } @@ -142,7 +147,6 @@ init_signals(on) * Process any signals we have received. * A received signal cause a bit to be set in "sigs". */ - public int psignals() { register int tsignals; @@ -175,25 +179,25 @@ psignals() * Clean up the terminal. */ #ifdef SIGTTOU - signal(SIGTTOU, SIG_IGN); + (void)signal(SIGTTOU, SIG_IGN); #endif lower_left(); clear_eol(); deinit(); - flush(); + (void)flush(); raw_mode(0); #ifdef SIGTTOU - signal(SIGTTOU, SIG_DFL); + (void)signal(SIGTTOU, SIG_DFL); #endif - signal(SIGTSTP, SIG_DFL); - kill(getpid(), SIGTSTP); + (void)signal(SIGTSTP, SIG_DFL); + (void)kill(getpid(), SIGTSTP); /* * ... Bye bye. ... * Hopefully we'll be back later and resume here... * Reset the terminal and arrange to repaint the * screen when we get back to the main command loop. */ - signal(SIGTSTP, stop); + (void)signal(SIGTSTP, stop); raw_mode(1); init(); screen_trashed = 1;