maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
signals.h File Reference
#include <termios.h>
#include <sys/ioctl.h>
#include <signal.h>
#include "shell.h"
Include dependency graph for signals.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 

Functions

void signal_reset_prompt (int signo)
 
void set_signals_interactive (void)
 
void signal_print_newline (int signal)
 
void sigquit_ignore (void)
 
void set_signals_noninteractive (void)
 
void handle_sigint_heredoc (int signo)
 
int ft_perror (char *str)
 

Variables

volatile sig_atomic_t g_heredoc_interrupted
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 15 of file signals.h.

Function Documentation

◆ ft_perror()

int ft_perror ( char *  str)

Definition at line 18 of file exit_status_utils.c.

19{
20 perror (str);
21 exit(EXIT_FAILURE);
22}
#define EXIT_FAILURE
Definition exit_status.h:17

◆ handle_sigint_heredoc()

void handle_sigint_heredoc ( int  signo)

Definition at line 19 of file signals_utils.c.

20{
21 (void)signo;
23 write(1, "\n", 1);
24 rl_replace_line("", 0);
25 rl_redisplay();
26}
volatile sig_atomic_t g_heredoc_interrupted

References g_heredoc_interrupted.

Referenced by setup_sigint_handler().

Here is the caller graph for this function:

◆ set_signals_interactive()

void set_signals_interactive ( void  )

Definition at line 51 of file signals.c.

52{
53 struct sigaction a;
54
56 sigemptyset(&a.sa_mask);
57 a.sa_flags = 0;
58 a.sa_handler = *signal_reset_prompt;
59 a.sa_flags |= SA_RESTART;
60 sigaction(SIGINT, &a, NULL);
61}
void signal_reset_prompt(int signo)
Definition signals.c:25
void sigquit_ignore(void)
Definition signals.c:41

References signal_reset_prompt(), and sigquit_ignore().

Referenced by main_loop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_signals_noninteractive()

void set_signals_noninteractive ( void  )

Definition at line 63 of file signals.c.

64{
65 struct sigaction a;
66
67 sigemptyset(&a.sa_mask);
68 a.sa_flags = 0;
69 a.sa_handler = &signal_print_newline;
70 sigaction(SIGINT, &a, NULL);
71 a.sa_handler = SIG_IGN;
72 sigaction(SIGQUIT, &a, NULL);
73}
void signal_print_newline(int signal)
Definition signals.c:34

References signal_print_newline().

Referenced by main_loop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ signal_print_newline()

void signal_print_newline ( int  signal)

Definition at line 34 of file signals.c.

35{
36 (void)signal;
37 write(STDOUT_FILENO, "\n", 1);
38 rl_on_new_line();
39}

Referenced by set_signals_noninteractive().

Here is the caller graph for this function:

◆ signal_reset_prompt()

void signal_reset_prompt ( int  signo)

Definition at line 25 of file signals.c.

26{
27 (void)signo;
28 write(1, "\n", 1);
29 rl_on_new_line();
30 rl_replace_line("", 0);
31 rl_redisplay();
32}

Referenced by set_signals_interactive().

Here is the caller graph for this function:

◆ sigquit_ignore()

void sigquit_ignore ( void  )

Definition at line 41 of file signals.c.

42{
43 struct sigaction a;
44
45 sigemptyset(&a.sa_mask);
46 a.sa_flags = 0;
47 a.sa_handler = SIG_IGN;
48 sigaction(SIGQUIT, &a, NULL);
49}

Referenced by set_signals_interactive().

Here is the caller graph for this function:

Variable Documentation

◆ g_heredoc_interrupted

volatile sig_atomic_t g_heredoc_interrupted
extern