maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
signals.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* signals.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: dmdemirk <dmdemirk@student.42london.c +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2024/07/17 13:59:59 by dmdemirk #+# #+# */
9/* Updated: 2024/09/09 12:32:04 by dmdemirk ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "signals.h"
14#include <readline/readline.h>
15#include <readline/history.h>
16#include <unistd.h>
17#include "libft.h"
18#include "exit_status.h"
19
20void signal_reset_prompt(int signo, siginfo_t *info, void *ucontext);
22void signal_print_newline(int signal);
23void sigquit_ignore(void);
25
26void signal_print_newline(int signal)
27{
28 (void)signal;
29 write(STDOUT_FILENO, "\n", 1);
30 rl_on_new_line();
31}
32
34{
35 struct sigaction a;
36
37 sigemptyset(&a.sa_mask);
38 a.sa_flags = 0;
39 a.sa_handler = SIG_IGN;
40 sigaction(SIGQUIT, &a, NULL);
41}
42
44{
45 struct sigaction sa;
46
47 (void)data;
48 sa.sa_sigaction = signal_reset_prompt;
49 sa.sa_flags = SA_RESTART | SA_SIGINFO;
50 sigemptyset(&sa.sa_mask);
51 sigaction(SIGINT, &sa, NULL);
52}
53
54void signal_reset_prompt(int signo, siginfo_t *info, void *ucontext)
55{
56 (void)signo;
57 (void)info;
58 (void)ucontext;
59 write(STDOUT_FILENO, "\n", 1);
60 rl_on_new_line();
61 rl_replace_line("", 0);
63 rl_redisplay();
64}
65
67{
68 struct sigaction sa;
69
70 sa.sa_handler = SIG_IGN;
71 sigemptyset(&sa.sa_mask);
72 sa.sa_flags = 0;
73 sigaction(SIGQUIT, &sa, NULL);
74}
void signal_reset_prompt(int signo, siginfo_t *info, void *ucontext)
Definition signals.c:54
void signal_print_newline(int signal)
Definition signals.c:26
void set_signals_interactive(t_ms_data *data)
Definition signals.c:43
void sigquit_ignore(void)
Definition signals.c:33
void set_signals_noninteractive(void)
Definition signals.c:66
int is_external_command_running(void)