mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
fix(exec): correctly exit subprocesses, do not keep multiple shells in parallel
This commit is contained in:
parent
2ea4afda4a
commit
733ae1093a
14 changed files with 81 additions and 46 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/07 10:38:55 by khais #+# #+# */
|
||||
/* Updated: 2025/04/11 12:02:02 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/16 16:56:20 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,28 +16,31 @@
|
|||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static void connec_and_cmd_execute(t_connec_cmd *cmd, t_minishell *app)
|
||||
static void connec_and_cmd_execute(t_connec_cmd *cmd, t_minishell *app,
|
||||
bool should_exit)
|
||||
{
|
||||
cmd_execute(cmd->first, app);
|
||||
cmd_execute(cmd->first, app, should_exit);
|
||||
if (app->last_return_value == 0)
|
||||
cmd_execute(cmd->second, app);
|
||||
cmd_execute(cmd->second, app, should_exit);
|
||||
}
|
||||
|
||||
static void connec_or_cmd_execute(t_connec_cmd *cmd, t_minishell *app)
|
||||
static void connec_or_cmd_execute(t_connec_cmd *cmd, t_minishell *app,
|
||||
bool should_exit)
|
||||
{
|
||||
cmd_execute(cmd->first, app);
|
||||
cmd_execute(cmd->first, app, should_exit);
|
||||
if (app->last_return_value != 0)
|
||||
cmd_execute(cmd->second, app);
|
||||
cmd_execute(cmd->second, app, should_exit);
|
||||
}
|
||||
|
||||
void connec_cmd_execute(t_connec_cmd *cmd, t_minishell *app)
|
||||
void connec_cmd_execute(t_connec_cmd *cmd, t_minishell *app,
|
||||
bool should_exit)
|
||||
{
|
||||
if (cmd == NULL)
|
||||
return ;
|
||||
if (cmd->connector == FT_AND)
|
||||
connec_and_cmd_execute(cmd, app);
|
||||
connec_and_cmd_execute(cmd, app, should_exit);
|
||||
if (cmd->connector == FT_OR)
|
||||
connec_or_cmd_execute(cmd, app);
|
||||
connec_or_cmd_execute(cmd, app, should_exit);
|
||||
if (cmd->connector == FT_PIPE)
|
||||
connec_pipe_cmd_execute(cmd, app);
|
||||
connec_pipe_cmd_execute(cmd, app, should_exit);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue