mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
Signal: basic signal handling. Correction.
This commit is contained in:
parent
83d88681a2
commit
776ce85255
2 changed files with 14 additions and 11 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jguelen <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/20 10:26:05 by jguelen #+# #+# */
|
||||
/* Updated: 2025/02/21 14:48:48 by jguelen ### ########.fr */
|
||||
/* Updated: 2025/02/21 15:32:57 by jguelen ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ static void sig_interactive(int signum)
|
|||
*/
|
||||
static void ignoreif_sent_by_kill(int signum, siginfo_t *siginfo, void *context)
|
||||
{
|
||||
(void *)context;
|
||||
(void)context;
|
||||
if (siginfo->si_code == SI_USER)
|
||||
return ;
|
||||
g_signum = signum;
|
||||
|
|
@ -34,9 +34,9 @@ int set_interactive_mode_sig_handling(void)
|
|||
{
|
||||
struct sigaction sig_act;
|
||||
|
||||
ft_bzero(&sig_act);
|
||||
sig_act.sa_handler = &sig_int_new_prompt;
|
||||
if (sigemptyset(sig_act.sa_mask) == -1)
|
||||
ft_bzero(&sig_act, sizeof(struct sigaction));
|
||||
sig_act.sa_handler = &sig_interactive;
|
||||
if (sigemptyset(&sig_act.sa_mask) == -1)
|
||||
return (-1);
|
||||
if (sigaction(SIGINT, &sig_act, NULL) == -1)
|
||||
return (-1);
|
||||
|
|
@ -50,8 +50,8 @@ int set_exec_mode_sig_handling(void)
|
|||
{
|
||||
struct sigaction sig_act;
|
||||
|
||||
ft_bzero(&sig_act);
|
||||
if (sigemptyset(sig_act.sa_mask) == -1)
|
||||
ft_bzero(&sig_act, sizeof(struct sigaction));
|
||||
if (sigemptyset(&sig_act.sa_mask) == -1)
|
||||
return (-1);
|
||||
sig_act.sa_sigaction = &ignoreif_sent_by_kill;
|
||||
sig_act.sa_flags |= SA_SIGINFO;
|
||||
|
|
@ -73,9 +73,9 @@ int set_default_sig_handling(void)
|
|||
struct sigaction sig;
|
||||
int i;
|
||||
|
||||
ft_bzero(&sig);
|
||||
ft_bzero(&sig, sizeof(struct sigaction));
|
||||
sig.sa_handler = SIG_DFL;
|
||||
if (sigemptyset(sig.sa_mask) == -1)
|
||||
if (sigemptyset(&sig.sa_mask) == -1)
|
||||
return (-1);
|
||||
i = 0;
|
||||
while (i < NSIG)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue