expander et signal

This commit is contained in:
Loic Deridder
2025-02-17 15:38:21 +01:00
parent a9cffbe6e3
commit 50ce870e5d
4 changed files with 49 additions and 4 deletions

View File

@@ -13,7 +13,9 @@
#include "../includes/minishell.h"
#include <readline/history.h>
#include <readline/readline.h>
#include <stdlib.h>
#include <termios.h>
#include <time.h>
int g_sig = 0;
@@ -36,10 +38,21 @@ static void add_prevhistory(t_msh *msh)
void handle_sigint(int sig)
{
(void)sig;
write(2, "\n\n", 2);
rl_on_new_line();
rl_replace_line("", 0);
rl_redisplay();
int status;
pid_t pid;
pid = waitpid(-1, &status, 0);
if (pid > 0 && (WIFSIGNALED(status) && WTERMSIG(status) == SIGINT))
{
write(2, "\n", 2);
}
else
{
write(2, "\n\n", 2);
rl_on_new_line();
rl_replace_line("", 0);
rl_redisplay();
}
g_sig = sig;
}