/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* do_waitpid.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/04 19:55:22 by khais #+# #+# */ /* Updated: 2025/04/28 12:29:50 by khais ### ########.fr */ /* */ /* ************************************************************************** */ #include "do_waitpid.h" #include "libft.h" #include #include #include void do_waitpid(t_minishell *app, int pid) { int wstatus; wstatus = 0; if (waitpid(pid, &wstatus, 0) == -1) { app->last_return_value = 255; perror("waitpid"); } 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)"); } }