1
/* -*- coding: utf-8 -*- */
3
* Passprompt - Read a password from the terminal and print it
5
* Copyright © 2007-2008 Teddy Hogeborn & Björn Påhlsson
7
* This program is free software: you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License as
9
* published by the Free Software Foundation, either version 3 of the
10
* License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see
19
* <http://www.gnu.org/licenses/>.
21
* Contact the authors at <https://www.fukt.bsnet.se/~belorn/> and
22
* <https://www.fukt.bsnet.se/~teddy/>.
1
25
#define _GNU_SOURCE /* getline() */
2
#define _FORTIFY_SOURCE 2
3
27
#include <termios.h> /* struct termios, tcsetattr(),
4
28
TCSAFLUSH, tcgetattr(), ECHO */
5
29
#include <unistd.h> /* struct termios, tcsetattr(),
79
103
sigemptyset(&new_action.sa_mask);
80
104
sigaddset(&new_action.sa_mask, SIGINT);
81
sigaddset(&new_action.sa_mask, SIGQUIT);
82
105
sigaddset(&new_action.sa_mask, SIGHUP);
83
106
sigaddset(&new_action.sa_mask, SIGTERM);
84
107
sigaction(SIGINT, NULL, &old_action);
85
108
if (old_action.sa_handler != SIG_IGN)
86
109
sigaction(SIGINT, &new_action, NULL);
87
sigaction(SIGQUIT, NULL, &old_action);
88
if (old_action.sa_handler != SIG_IGN)
89
sigaction(SIGQUIT, &new_action, NULL);
90
110
sigaction(SIGHUP, NULL, &old_action);
91
111
if (old_action.sa_handler != SIG_IGN)
92
112
sigaction(SIGHUP, &new_action, NULL);