mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
fix(sig): incorrect retvalue when doing C-c on empty line
Now correctly return 130 Closes #196
This commit is contained in:
parent
ff3dfe3b84
commit
52c33abb16
4 changed files with 16 additions and 13 deletions
|
|
@ -5,8 +5,8 @@
|
|||
/* +:+ +:+ +:+ */
|
||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/29 15:13/45 by kcolin #+# #+# */
|
||||
/* Updated: 2025/04/29 15:13:45 by kcolin ### ########.fr */
|
||||
/* Created: 2025/05/02 11:53:53 by kcolin #+# #+# */
|
||||
/* Updated: 2025/05/02 12:07:42 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
#include "postprocess/fieldsplit/fieldsplit.h"
|
||||
#include "postprocess/expansion/expand_wildcard.h"
|
||||
#include "sig/sig.h"
|
||||
#include "sig/sig_handlers.h"
|
||||
#include "parser/cmd/cmd_debug.h"
|
||||
|
||||
/*
|
||||
|
|
@ -88,6 +89,8 @@ int main(int argc, char *argv[], char **envp)
|
|||
line = get_command(&app);
|
||||
while (line != NULL)
|
||||
{
|
||||
if (g_signum != 0)
|
||||
app.last_return_value = get_sig_retvalue();
|
||||
cmd = minishell_parse(&app, line);
|
||||
free(line);
|
||||
debug_command(cmd, &app);
|
||||
|
|
@ -95,8 +98,6 @@ int main(int argc, char *argv[], char **envp)
|
|||
cmd_destroy(cmd);
|
||||
if (retvalue == SUBPROCESS)
|
||||
break ;
|
||||
if (g_signum != 0)
|
||||
readline_reset();
|
||||
line = get_command(&app);
|
||||
}
|
||||
env_destroy(app.env);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/19 18:21:55 by jguelen #+# #+# */
|
||||
/* Updated: 2025/04/17 12:05:05 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/05/02 11:53:24 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -32,6 +32,5 @@ extern int g_signum;
|
|||
int set_interactive_mode_sig_handling(void);
|
||||
int set_exec_mode_sig_handling(void);
|
||||
int set_here_doc_mode_sig_handling(void);
|
||||
void readline_reset(void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/17 12:01:39 by kcolin #+# #+# */
|
||||
/* Updated: 2025/04/29 15:13:42 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/05/02 12:03:49 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -28,15 +28,17 @@ void sig_interactive(int signum)
|
|||
ft_printf("\n");
|
||||
rl_on_new_line();
|
||||
rl_redisplay();
|
||||
g_signum = signum;
|
||||
}
|
||||
}
|
||||
|
||||
void readline_reset(void)
|
||||
int get_sig_retvalue(void)
|
||||
{
|
||||
rl_replace_line("", 0);
|
||||
ft_printf("\n");
|
||||
rl_redisplay();
|
||||
int retvalue;
|
||||
|
||||
retvalue = 128 + g_signum;
|
||||
g_signum = 0;
|
||||
return (retvalue);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -46,5 +48,6 @@ void sig_cmd(int signum, siginfo_t *siginfo, void *context)
|
|||
{
|
||||
(void)context;
|
||||
(void)siginfo;
|
||||
ft_printf("\n");
|
||||
g_signum = signum;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/17 12:01:25 by kcolin #+# #+# */
|
||||
/* Updated: 2025/04/17 12:03:07 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/05/02 12:03:53 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
# include "signal.h"
|
||||
|
||||
void sig_interactive(int signum);
|
||||
void readline_reset(void);
|
||||
int get_sig_retvalue(void);
|
||||
void sig_cmd(int signum, siginfo_t *siginfo, void *context);
|
||||
|
||||
#endif // SIG_HANDLERS_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue