MiniDevil As beautiful as a shell
ui_signals.c
Go to the documentation of this file.
1 /* ************************************************************************** */
2 /* */
3 /* ::: :::::::: */
4 /* ui_signals.c :+: :+: :+: */
5 /* +:+ +:+ +:+ */
6 /* By: baelgadi <baelgadi@student.42.fr> +#+ +:+ +#+ */
7 /* +#+#+#+#+#+ +#+ */
8 /* Created: 2026/02/18 17:11:06 by zotaj-di #+# #+# */
9 /* Updated: 2026/03/04 04:56:09 by baelgadi ### ########.fr */
10 /* */
11 /* ************************************************************************** */
12 
13 #include "minishell_ui.h"
14 
20 static void handle_ui_sigwinch(int sig)
21 {
22  g_signal = sig;
23 }
24 
31 void setup_ui_signals(void)
32 {
33  struct sigaction sa_winch;
34  struct sigaction sa_int;
35 
36  ft_memset(&sa_winch, 0, sizeof(sa_winch));
37  sa_winch.sa_handler = handle_ui_sigwinch;
38  sigemptyset(&sa_winch.sa_mask);
39  sa_winch.sa_flags = SA_RESTART;
40  sigaction(SIGWINCH, &sa_winch, NULL);
41  ft_memset(&sa_int, 0, sizeof(sa_int));
42  sa_int.sa_handler = SIG_IGN;
43  sigemptyset(&sa_int.sa_mask);
44  sa_int.sa_flags = 0;
45  sigaction(SIGINT, &sa_int, NULL);
46 }
UI mode structures, macros & function prototypes.
volatile sig_atomic_t g_signal
The single global variable.
Definition: signals.c:17
static void handle_ui_sigwinch(int sig)
Records SIGWINCH in the global signal flag.
Definition: ui_signals.c:20
void setup_ui_signals(void)
Set up SIGWINCH and SIGINT handlers for the UI loop.
Definition: ui_signals.c:31