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> +#+ +:+ +#+ */
|
/* By: jguelen <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/20 10:26:05 by jguelen #+# #+# */
|
/* 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)
|
static void ignoreif_sent_by_kill(int signum, siginfo_t *siginfo, void *context)
|
||||||
{
|
{
|
||||||
(void *)context;
|
(void)context;
|
||||||
if (siginfo->si_code == SI_USER)
|
if (siginfo->si_code == SI_USER)
|
||||||
return ;
|
return ;
|
||||||
g_signum = signum;
|
g_signum = signum;
|
||||||
|
|
@ -34,9 +34,9 @@ int set_interactive_mode_sig_handling(void)
|
||||||
{
|
{
|
||||||
struct sigaction sig_act;
|
struct sigaction sig_act;
|
||||||
|
|
||||||
ft_bzero(&sig_act);
|
ft_bzero(&sig_act, sizeof(struct sigaction));
|
||||||
sig_act.sa_handler = &sig_int_new_prompt;
|
sig_act.sa_handler = &sig_interactive;
|
||||||
if (sigemptyset(sig_act.sa_mask) == -1)
|
if (sigemptyset(&sig_act.sa_mask) == -1)
|
||||||
return (-1);
|
return (-1);
|
||||||
if (sigaction(SIGINT, &sig_act, NULL) == -1)
|
if (sigaction(SIGINT, &sig_act, NULL) == -1)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
@ -50,8 +50,8 @@ int set_exec_mode_sig_handling(void)
|
||||||
{
|
{
|
||||||
struct sigaction sig_act;
|
struct sigaction sig_act;
|
||||||
|
|
||||||
ft_bzero(&sig_act);
|
ft_bzero(&sig_act, sizeof(struct sigaction));
|
||||||
if (sigemptyset(sig_act.sa_mask) == -1)
|
if (sigemptyset(&sig_act.sa_mask) == -1)
|
||||||
return (-1);
|
return (-1);
|
||||||
sig_act.sa_sigaction = &ignoreif_sent_by_kill;
|
sig_act.sa_sigaction = &ignoreif_sent_by_kill;
|
||||||
sig_act.sa_flags |= SA_SIGINFO;
|
sig_act.sa_flags |= SA_SIGINFO;
|
||||||
|
|
@ -73,9 +73,9 @@ int set_default_sig_handling(void)
|
||||||
struct sigaction sig;
|
struct sigaction sig;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
ft_bzero(&sig);
|
ft_bzero(&sig, sizeof(struct sigaction));
|
||||||
sig.sa_handler = SIG_DFL;
|
sig.sa_handler = SIG_DFL;
|
||||||
if (sigemptyset(sig.sa_mask) == -1)
|
if (sigemptyset(&sig.sa_mask) == -1)
|
||||||
return (-1);
|
return (-1);
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < NSIG)
|
while (i < NSIG)
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,21 @@
|
||||||
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/19 18:21:55 by jguelen #+# #+# */
|
/* Created: 2025/02/19 18:21:55 by jguelen #+# #+# */
|
||||||
/* Updated: 2025/02/21 13:52:47 by jguelen ### ########.fr */
|
/* Updated: 2025/02/21 15:26:59 by jguelen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef SIG_H
|
#ifndef SIG_H
|
||||||
# define SIG_H
|
# define SIG_H
|
||||||
|
|
||||||
|
# include "libft.h"
|
||||||
# include <signal.h>
|
# include <signal.h>
|
||||||
# include <stddef.h>
|
# include <stddef.h>
|
||||||
# include <asm-generic/signal-defs.h>
|
# include <asm-generic/signal-defs.h>
|
||||||
|
|
||||||
# define NSIG 64
|
# ifndef NSIG
|
||||||
|
# define NSIG 64
|
||||||
|
# endif
|
||||||
|
|
||||||
extern int g_signum;
|
extern int g_signum;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue