Commit dd259218 authored by abenoit's avatar abenoit
Browse files

signal handling overhaul

parent fa404a47
......@@ -5,26 +5,32 @@ et tester sur bash "exit 42 1431" ou "exit fds"
arthur:
===========================Resolu
commande "."
-->Le leaks releve a la sortie d'execve ne serait pas a prendre en compte car l'os reprend la main sur les adresses de la pile du process qu'execve remplace:
https://linuxfr.org/forums/programmation-c--2/posts/free-apres-un-exec
============================Resolu
print newline after "^C" for CTRL-C signal ("cat")
same for CTRL-\, after "^\Quit"
===========================???
CTRL-D apres avoir ecrit un debut de cmd
==========================A regler dans le parsing ?
$unknown_var ; ls ; ls (premiere commande vide mais il fait quand meme ls)
========================Resolu
echo > $unknown_var ; ls ; ls (redir ambigue mais il fait quand meme ls)
=======================Resolu
create file when redirecting output without doing anything ("> a")
====================
error when redir_in file does not exist ("< unknown_file")
error when redir_out file does not have write permission
commande "."
compare with bash: "cat | exit"
"cat |"
......
......@@ -59,10 +59,22 @@ int parent_pipe_end(t_command *cur_command, t_xe *xe, int fd_in, int proc)
while (i < proc)
{
wait(&xe->stat_loc);
if(WIFEXITED(xe->stat_loc))
if (WIFSIGNALED(xe->stat_loc))
{
if (WTERMSIG(xe->stat_loc) == SIGQUIT)
{
if (ft_putstr_fd("\b\b^\\Quit (core dumped)\n", STDERR_FILENO) != WRITE_SUCCESS)
return (WRITE_ERR);
}
else
{
if (ft_putstr_fd("\n", STDERR_FILENO) != WRITE_SUCCESS)
return (WRITE_ERR);
}
xe->stat_loc = (xe->stat_loc % 256) + 128;
}
else if(WIFEXITED(xe->stat_loc))
xe->stat_loc = WEXITSTATUS(xe->stat_loc);
// if (WIFSIGNALED(xe->stat_loc)) // check this return value!
// xe->stat_loc += 128;
i++;
}
if (ret != SUCCESS)
......
......@@ -74,7 +74,22 @@ static int exec_cmd(char *cmd, char **args, t_xe *xe)
signal(SIGINT, SIG_IGN); // error if SIG_ERR? (check errno)
signal(SIGQUIT, SIG_IGN); // error if SIG_ERR? (check errno)
waitpid(pid, &xe->stat_loc, 0); // return value? error?
if(WIFEXITED(xe->stat_loc))
if (WIFSIGNALED(xe->stat_loc))
{
xe->stat_loc = WTERMSIG(xe->stat_loc);
if (xe->stat_loc == SIGQUIT)
{
if (ft_putstr_fd("\b\b^\\Quit (core dumped)\n", STDERR_FILENO) != WRITE_SUCCESS)
return (WRITE_ERR);
}
else
{
if (ft_putstr_fd("\n", STDERR_FILENO) != WRITE_SUCCESS)
return (WRITE_ERR);
}
xe->stat_loc += 128;
}
else if(WIFEXITED(xe->stat_loc))
xe->stat_loc = WEXITSTATUS(xe->stat_loc);
signal_handler(); // err
return (SUCCESS);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment