mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-03-15 03:16:51 +01:00
「🔨」 fix: fixed some bullshit
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/20 20:25:06 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/16 14:20:19 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/16 14:32:44 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -31,4 +31,6 @@ char *get_program_name(char *argv_one);
|
||||
bool send_error_parsing(char *msg);
|
||||
bool check_space(char *rl);
|
||||
|
||||
//free(*get_rl(NULL));
|
||||
|
||||
#endif
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/01 14:55:06 by mmoussou #+# #+# */
|
||||
/* Updated: 2024/07/15 21:03:12 by mmoussou ### ########.fr */
|
||||
/* Updated: 2024/07/16 14:36:38 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include "execution.h"
|
||||
|
||||
void __sig(int status);
|
||||
void __sig2(int status);
|
||||
|
||||
int exec_fork_cmd(t_cmd *cmd, char **env, t_env *env_t, int pipe_fd[2])
|
||||
{
|
||||
@ -89,6 +90,7 @@ t_exec exec_pipe_unforked(t_exec exec, t_list *list_cmd, t_env *env)
|
||||
|
||||
t_exec exec_pipe(t_exec exec, t_list *list_cmd, t_env *env)
|
||||
{
|
||||
__sig(exec.status);
|
||||
if (!list_cmd->next)
|
||||
return (exec_pipe_unforked(exec, list_cmd, env));
|
||||
while (list_cmd->next)
|
||||
@ -110,7 +112,7 @@ t_exec exec_pipe(t_exec exec, t_list *list_cmd, t_env *env)
|
||||
}
|
||||
exec.status = exec_fork_cmd(list_cmd->content, exec.env_array, \
|
||||
env, exec.pipe_fd);
|
||||
__sig(exec.status);
|
||||
__sig2(exec.status);
|
||||
__close(list_cmd->content);
|
||||
return (exec);
|
||||
}
|
||||
|
36
src/exec/sig.c
Normal file
36
src/exec/sig.c
Normal file
@ -0,0 +1,36 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* sig.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/16 14:38:11 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/16 14:38:58 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void ign(int signal)
|
||||
{
|
||||
(void) signal;
|
||||
}
|
||||
|
||||
void __sig2(int status)
|
||||
{
|
||||
if (WIFSIGNALED(status) && WTERMSIG(status) == SIGQUIT)
|
||||
{
|
||||
get_exit_code(131);
|
||||
if (WCOREDUMP(status))
|
||||
ft_putendl_fd("Quit (core dumped)", 2);
|
||||
else
|
||||
ft_putendl_fd("Quit", 2);
|
||||
}
|
||||
}
|
||||
|
||||
void __sig(void)
|
||||
{
|
||||
signal(SIGQUIT, ign);
|
||||
signal(SIGINT, ign);
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/09 22:53:01 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/15 17:05:33 by mmoussou ### ########.fr */
|
||||
/* Updated: 2024/07/16 14:39:09 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -37,16 +37,3 @@ int send_error_exec(char *input)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
void __sig(int status)
|
||||
{
|
||||
if (WIFSIGNALED(status) && WTERMSIG(status) == SIGQUIT)
|
||||
{
|
||||
get_exit_code(131);
|
||||
if (WCOREDUMP(status))
|
||||
ft_putendl_fd("Quit (core dumped)", 2);
|
||||
else
|
||||
ft_putendl_fd("Quit", 2);
|
||||
}
|
||||
signal(SIGQUIT, SIG_IGN);
|
||||
signal(SIGINT, SIG_IGN);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/24 11:18:04 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/16 14:20:42 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/16 14:40:35 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -72,6 +72,7 @@ int main(int ac, char **av, char **env)
|
||||
free(prompt);
|
||||
if (!rl)
|
||||
{
|
||||
ft_putendl_fd("exit", STDOUT_FILENO);
|
||||
get_exit_code(0);
|
||||
break ;
|
||||
}
|
||||
|
@ -6,11 +6,12 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/28 18:09:49 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/03 16:15:52 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/16 14:26:39 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
#include "minishell.h"
|
||||
|
||||
char *get_program_name(char *argv_one)
|
||||
{
|
||||
@ -26,5 +27,6 @@ bool send_error_parsing(char *msg)
|
||||
ft_putstr_fd(get_program_name(NULL), STDERR_FILENO);
|
||||
ft_putstr_fd(": Error: ", STDERR_FILENO);
|
||||
ft_putendl_fd(msg, STDERR_FILENO);
|
||||
get_exit_code(2);
|
||||
return (true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user