diff options
-rw-r--r-- | src/e_builtins.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/e_builtins.c b/src/e_builtins.c index c76f438..607292e 100644 --- a/src/e_builtins.c +++ b/src/e_builtins.c @@ -21,6 +21,37 @@ #include "s_lcom.h" #include "s_struct.h" +static void + e_builtin_child(const t_lcom *ptr, + uint8_t bu_id, + t_msh *msh) +{ + int32_t ret; + + dup_redirs(ptr, msh); + ret = msh->bu_ptr[bu_id](ptr->argv + 1, msh); + lcom_clear(&msh->curr); + s_destroy(msh); + exit(ret); +} + +static void + e_builtin_parent(pid_t pid, + const t_lcom *ptr, + uint8_t bu_id, + t_msh *msh) +{ + int32_t status; + int32_t ret; + + (void)ptr; + while (wait(&status) != pid) + ; + ret = WEXITSTATUS(status); + if (bu_id != FT_ID_EXIT) + msh->ret = ret; +} + void e_builtin(const t_lcom *ptr, uint8_t bu_id, |