File: winch.c

package info (click to toggle)
netrik 1.16.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, stretch
  • size: 3,272 kB
  • ctags: 729
  • sloc: ansic: 6,657; sh: 994; makefile: 114
file content (44 lines) | stat: -rw-r--r-- 1,206 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
   netrik -- The ANTRIK Internet Viewer
   Copyright (C) Olaf D. Buddenhagen AKA antrik, et al (see AUTHORS)
   Published under the GNU GPL; see LICENSE for details.
*/

/*
 * winch.c -- SIGWINCH handling
 *
 * (C) 2003 antrik
 *
 * This file contains functions for setting method of processing (immediate
 * delivery or hold) the winch signal (window change), raised by the terminal
 * when the terminal size changes. (e.g. xterm resize)
 */

#include <signal.h>
#include <stdlib.h>

#include "winch.h"

/* block signals, so they will neither be deliverd immediately nor discared;
 * instead, they will arrive as soon as enable_winch() is called */
void hold_winch(void)
{
   static sigset_t	winch_mask;    /* signal mask with only SIGWINCH set */

   sigemptyset(&winch_mask);
   sigaddset(&winch_mask, SIGWINCH);

   sigprocmask(SIG_BLOCK, &winch_mask, NULL);
}

/* release SIGWINCH (allows signals now, but also releases pending signals that
 * arrived during the hold period) */
void enable_winch(void)
{
   static sigset_t	winch_mask;    /* signal mask with only SIGWINCH set */

   sigemptyset(&winch_mask);
   sigaddset(&winch_mask, SIGWINCH);

   sigprocmask(SIG_UNBLOCK, &winch_mask, NULL);
}