File: signal_handling.c

package info (click to toggle)
slmon 0.5.13-2.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 504 kB
  • ctags: 210
  • sloc: sh: 2,912; ansic: 1,800; makefile: 60
file content (70 lines) | stat: -rw-r--r-- 1,276 bytes parent folder | download | duplicates (3)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * slmon
 *
 * Copyright (C) 2000, 2001, 2002 Krzysztof Luks <m00se@iq.pl>
 *
 * This program is distributed under the GPL license. For details see
 * COPYING text.
 *
 * Author: Krzysztof Luks <m00se@iq.pl>
 *
 * $Date: 2003/06/07 18:08:18 $
 * $Revision: 1.1.1.1 $
 *
 */

#include "signal_handling.h"
#include "defines.h"

/*
 * Things that need to be done before exiting
 */

void cleanup(int sig)
{
    SLtt_set_cursor_visibility(1);
    SLang_reset_tty();
    SLsmg_reset_smg();
    glibtop_close();
    exit(sig);
}

/*
 * Signal handlers initialistion
 */

void init_signals(void)
{
    SLsignal(SIGWINCH, handleSIGWINCH);
    SLsignal(SIGKILL, cleanup);
    SLsignal(SIGINT, cleanup);
    SLsignal(SIGQUIT, cleanup);
    SLsignal(SIGSTOP, cleanup);
    SLsignal(SIGTERM, cleanup);
    SLsignal(SIGSEGV, cleanup);
}

/*
 * SIGWINCH handler: resize the display
 */

void handleSIGWINCH(int signal)
{
    extern int redraw;

    SLsig_block_signals();
    SLtt_get_terminfo();
    SLsmg_reset_smg();
    SLsmg_init_smg();
    SLtt_get_screen_size();
    SLsmg_cls();

    redraw = 1;
    pos = 0;
    height = SLtt_Screen_Rows;
    draw_status();
    clear_histogram();
    SLsmg_refresh();
    SLsig_unblock_signals();
    SLsignal_intr(SIGWINCH, handleSIGWINCH);
}