Deleted Added
full compact
signals.c (43578) signals.c (56165)
1/* signals.c -- Install and maintain Info signal handlers. */
1/* signals.c -- install and maintain Info signal handlers.
2 $Id: signals.c,v 1.6 1998/12/06 22:00:04 karl Exp $
3 $FreeBSD: head/contrib/texinfo/info/signals.c 56165 2000-01-17 10:50:35Z ru $
2
4
3/* This file is part of GNU Info, a program for reading online documentation
4 stored in Info format.
5 Copyright (C) 1993, 94, 95, 98 Free Software Foundation, Inc.
5
6
6 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

--- 9 unchanged lines hidden (view full) ---

25#include "signals.h"
26
27/* **************************************************************** */
28/* */
29/* Pretending That We Have POSIX Signals */
30/* */
31/* **************************************************************** */
32
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

--- 9 unchanged lines hidden (view full) ---

24#include "signals.h"
25
26/* **************************************************************** */
27/* */
28/* Pretending That We Have POSIX Signals */
29/* */
30/* **************************************************************** */
31
32/* Non-zero when our signal handler has been called to handle SIGWINCH. */
33static int in_sigwinch = 0;
34
33#if !defined (HAVE_SIGPROCMASK) && defined (HAVE_SIGSETMASK)
34/* Perform OPERATION on NEWSET, perhaps leaving information in OLDSET. */
35static void
36sigprocmask (operation, newset, oldset)
37 int operation, *newset, *oldset;
38{
39 switch (operation)
40 {

--- 20 unchanged lines hidden (view full) ---

61/* Signal Handling for Info */
62/* */
63/* **************************************************************** */
64
65typedef RETSIGTYPE signal_handler ();
66
67static RETSIGTYPE info_signal_handler ();
68static signal_handler *old_TSTP, *old_TTOU, *old_TTIN;
35#if !defined (HAVE_SIGPROCMASK) && defined (HAVE_SIGSETMASK)
36/* Perform OPERATION on NEWSET, perhaps leaving information in OLDSET. */
37static void
38sigprocmask (operation, newset, oldset)
39 int operation, *newset, *oldset;
40{
41 switch (operation)
42 {

--- 20 unchanged lines hidden (view full) ---

63/* Signal Handling for Info */
64/* */
65/* **************************************************************** */
66
67typedef RETSIGTYPE signal_handler ();
68
69static RETSIGTYPE info_signal_handler ();
70static signal_handler *old_TSTP, *old_TTOU, *old_TTIN;
69static signal_handler *old_WINCH, *old_INT, *old_CONT;
71static signal_handler *old_WINCH, *old_INT, *old_USR1, *old_CONT;
70
71void
72initialize_info_signal_handler ()
73{
74#if defined (SIGTSTP)
75 old_TSTP = (signal_handler *) signal (SIGTSTP, info_signal_handler);
76 old_TTOU = (signal_handler *) signal (SIGTTOU, info_signal_handler);
77 old_TTIN = (signal_handler *) signal (SIGTTIN, info_signal_handler);
78#endif /* SIGTSTP */
79
80#if defined (SIGWINCH)
81 old_WINCH = (signal_handler *) signal (SIGWINCH, info_signal_handler);
82#if defined (SIGCONT)
83 old_CONT = (signal_handler *) signal (SIGCONT, info_signal_handler);
72
73void
74initialize_info_signal_handler ()
75{
76#if defined (SIGTSTP)
77 old_TSTP = (signal_handler *) signal (SIGTSTP, info_signal_handler);
78 old_TTOU = (signal_handler *) signal (SIGTTOU, info_signal_handler);
79 old_TTIN = (signal_handler *) signal (SIGTTIN, info_signal_handler);
80#endif /* SIGTSTP */
81
82#if defined (SIGWINCH)
83 old_WINCH = (signal_handler *) signal (SIGWINCH, info_signal_handler);
84#if defined (SIGCONT)
85 old_CONT = (signal_handler *) signal (SIGCONT, info_signal_handler);
84#endif /* SIGCONT */
85#endif
86#endif
87#endif
86
87#if defined (SIGINT)
88 old_INT = (signal_handler *) signal (SIGINT, info_signal_handler);
89#endif
88
89#if defined (SIGINT)
90 old_INT = (signal_handler *) signal (SIGINT, info_signal_handler);
91#endif
92
93#if defined (SIGUSR1)
94 /* Used by DJGPP to simulate SIGTSTP on Ctrl-Z. */
95 old_USR1 = (signal_handler *) signal (SIGUSR1, info_signal_handler);
96#endif
90}
91
92static void
93redisplay_after_signal ()
94{
95 terminal_clear_screen ();
96 display_clear_display (the_display);
97 window_mark_chain (windows, W_UpdateWindow);
98 display_update_display (windows);
99 display_cursor_at_point (active_window);
100 fflush (stdout);
101}
102
97}
98
99static void
100redisplay_after_signal ()
101{
102 terminal_clear_screen ();
103 display_clear_display (the_display);
104 window_mark_chain (windows, W_UpdateWindow);
105 display_update_display (windows);
106 display_cursor_at_point (active_window);
107 fflush (stdout);
108}
109
110static void
111reset_info_window_sizes ()
112{
113 terminal_goto_xy (0, 0);
114 fflush (stdout);
115 terminal_unprep_terminal ();
116 terminal_get_screen_size ();
117 terminal_prep_terminal ();
118 display_initialize_display (screenwidth, screenheight);
119 window_new_screen_size (screenwidth, screenheight, NULL);
120 redisplay_after_signal ();
121}
122
103static RETSIGTYPE
104info_signal_handler (sig)
105 int sig;
106{
107 signal_handler **old_signal_handler;
108
109 switch (sig)
110 {

--- 32 unchanged lines hidden (view full) ---

143 cursor where it belongs. */
144 terminal_prep_terminal ();
145 *old_signal_handler = (signal_handler *) signal (sig, info_signal_handler);
146 redisplay_after_signal ();
147 fflush (stdout);
148 }
149 break;
150
123static RETSIGTYPE
124info_signal_handler (sig)
125 int sig;
126{
127 signal_handler **old_signal_handler;
128
129 switch (sig)
130 {

--- 32 unchanged lines hidden (view full) ---

163 cursor where it belongs. */
164 terminal_prep_terminal ();
165 *old_signal_handler = (signal_handler *) signal (sig, info_signal_handler);
166 redisplay_after_signal ();
167 fflush (stdout);
168 }
169 break;
170
151#if defined (SIGWINCH)
152#if defined(SIGCONT)
171#if defined (SIGWINCH) || defined (SIGUSR1)
172#ifdef SIGWINCH
173#ifdef SIGCONT
153 case SIGCONT:
174 case SIGCONT:
154 if (old_CONT)
155 (void)(old_CONT)(sig);
156 /* pretend a SIGWINCH in case the terminal window size has changed
157 while we've been asleep */
175 /* pretend a SIGWINCH in case the terminal window size has changed
176 while we've been asleep */
158 /* FALLTROUGH */
159#endif /* defined(SIGCONT) */
160
177 /* FALLTHROUGH */
178#endif
161 case SIGWINCH:
179 case SIGWINCH:
180#endif
181#ifdef SIGUSR1
182 case SIGUSR1:
183#endif
162 {
184 {
163 /* Turn off terminal IO, tell our parent that the window has changed,
164 then reinitialize the terminal and rebuild our windows. */
165 old_signal_handler = &old_WINCH;
166 terminal_goto_xy (0, 0);
167 fflush (stdout);
168 terminal_unprep_terminal ();
169 signal (sig, *old_signal_handler);
170 UNBLOCK_SIGNAL (sig);
171 kill (getpid (), sig);
185 if (!in_sigwinch) {
186 in_sigwinch++;
187
188 /* Turn off terminal IO, tell our parent that the window has changed,
189 then reinitialize the terminal and rebuild our windows. */
190#ifdef SIGWINCH
191 if (sig == SIGWINCH)
192 old_signal_handler = &old_WINCH;
193#ifdef SIGCONT
194 else if (sig == SIGCONT)
195 old_signal_handler = &old_CONT;
196#endif
197#endif
198#ifdef SIGUSR1
199 if (sig == SIGUSR1)
200 old_signal_handler = &old_USR1;
201#endif
202 terminal_goto_xy (0, 0);
203 fflush (stdout);
204 terminal_unprep_terminal ();
205 signal (sig, *old_signal_handler);
206 UNBLOCK_SIGNAL (sig);
207 kill (getpid (), sig);
172
208
173 /* After our old signal handler returns... */
174 terminal_get_screen_size ();
175 terminal_prep_terminal ();
176 display_initialize_display (screenwidth, screenheight);
177 window_new_screen_size (screenwidth, screenheight, (VFunction *)NULL);
178 *old_signal_handler = (signal_handler *) signal (sig, info_signal_handler);
179 redisplay_after_signal ();
209 /* After our old signal handler returns... */
210 *old_signal_handler
211 = (signal_handler *) signal (sig, info_signal_handler);
212 terminal_prep_terminal ();
213 reset_info_window_sizes ();
214 in_sigwinch--;
215 }
180 }
181 break;
216 }
217 break;
182#endif /* SIGWINCH */
218#endif /* SIGWINCH || SIGUSR1 */
183 }
184}
219 }
220}