mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
refactor(do_waitpid): put into own file for easier acces from other modules
This commit is contained in:
parent
f9f8a804a3
commit
425722801b
4 changed files with 54 additions and 17 deletions
|
|
@ -6,16 +6,16 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/27 16:21:56 by khais #+# #+# */
|
||||
/* Updated: 2025/04/02 19:15:08 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/04 17:09:39 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "simple_cmd_execute.h"
|
||||
#include "builtins.h"
|
||||
#include "signal.h"
|
||||
#include "subprocess.h"
|
||||
#include "libft.h"
|
||||
#include "../../subst/subst.h"
|
||||
#include "../common/do_waitpid.h"
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -27,21 +27,6 @@ static void command_not_found(t_simple_cmd *cmd)
|
|||
cmd->words->word->word);
|
||||
}
|
||||
|
||||
static void do_waitpid(t_minishell *app, int pid)
|
||||
{
|
||||
int wstatus;
|
||||
|
||||
waitpid(pid, &wstatus, 0);
|
||||
if (WIFEXITED(wstatus))
|
||||
app->last_return_value = WEXITSTATUS(wstatus);
|
||||
if (WIFSIGNALED(wstatus))
|
||||
{
|
||||
app->last_return_value = 128 + WTERMSIG(wstatus);
|
||||
if (WTERMSIG(wstatus) == SIGQUIT)
|
||||
ft_dprintf(STDERR_FILENO, "Quit (core dumped)");
|
||||
}
|
||||
}
|
||||
|
||||
void simple_cmd_execute(t_simple_cmd *cmd, t_minishell *app)
|
||||
{
|
||||
char *exe;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue