maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
signals_utils.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* signals_utils.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: rocky <marvin@42.fr> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2024/09/06 13:43:47 by rocky #+# #+# */
9
/* Updated: 2024/09/06 13:43:49 by rocky ### ########.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 <sys/wait.h>
19
20
// Pulls ms_data into sigint handler, bypassing need of second global variable
21
t_signal_context
*
get_context
(
t_ms_data
*data)
22
{
23
static
t_signal_context
*context = NULL;
24
25
if
(data != NULL)
26
{
27
if
(!context)
28
{
29
context = malloc(
sizeof
(
t_signal_context
));
30
if
(!context)
31
return
(NULL);
32
}
33
context->
data_cxt
= data;
34
}
35
return
(context);
36
}
37
38
void
handle_sigint_heredoc
(
int
signo)
39
{
40
(void)signo;
41
g_heredoc_interrupted
= 1;
42
}
43
44
int
is_external_command_running
(
void
)
45
{
46
pid_t child_pid;
47
48
child_pid = waitpid(-1, NULL, WNOHANG);
49
if
(child_pid == 0)
50
return
(1);
51
else
52
return
(0);
53
}
libft.h
signals.h
g_heredoc_interrupted
volatile sig_atomic_t g_heredoc_interrupted
Definition
redirect_heredoc.c:27
handle_sigint_heredoc
void handle_sigint_heredoc(int signo)
Definition
signals_utils.c:38
is_external_command_running
int is_external_command_running(void)
Definition
signals_utils.c:44
get_context
t_signal_context * get_context(t_ms_data *data)
Definition
signals_utils.c:21
s_ms_data
Definition
shell.h:21
s_signal_context
Definition
signals.h:23
s_signal_context::data_cxt
t_ms_data * data_cxt
Definition
signals.h:24
src
signals
signals_utils.c
Generated by
1.9.8