From 2880d4104a8a2c769cd9e5889fb3df8f06fde792 Mon Sep 17 00:00:00 2001 From: Kyungjun Lee Date: Mon, 8 Apr 2024 17:28:49 +0900 Subject: [PATCH] ast: ongoing... --- codes/includes/loader.h | 8 ++++---- codes/loader/ldexec_run.c | 29 +++++++++++++---------------- codes/loader/ldpre_ast.c | 19 +++++++++++-------- codes/loader/loader_wrapper.c | 4 ++-- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/codes/includes/loader.h b/codes/includes/loader.h index 81e4745..ce3faa2 100644 --- a/codes/includes/loader.h +++ b/codes/includes/loader.h @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* loader.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: kyungjle +#+ +:+ +#+ */ +/* By: nicknamemohaji +#+ +:+ +#+ */ +/* By: nicknamemohaji exitcode = builtin_wrapper(exec, env); } else - pid = ldexec_run_bin(exec); + pid = ldexec_run_bin(exec, pid); node->pid = pid; } diff --git a/codes/loader/ldpre_ast.c b/codes/loader/ldpre_ast.c index 746699c..bb59a94 100644 --- a/codes/loader/ldpre_ast.c +++ b/codes/loader/ldpre_ast.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* ldpre_ast.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: kyungjle +#+ +:+ +#+ */ +/* By: nicknamemohaji exec).envp = ldpre_env_toenvp_f(env); (node->exec).path = ldexec_exec_find_f( (node->exec).argv[0], &free_flag, ldpre_env_fetch("PATH", env)); + + // 2. 실행 + // 2-1. 파이프이면 fork if (exec != NULL) { pid = fork(); @@ -46,11 +48,13 @@ int ldpre_ast(t_ast_node *ast, t_ld_map_env *env, } else pid = -1; + // 2-2. !PIPE || (PIPE && CHILD) if (pid <= 0) { - ldexec_select_type(node->exec, node, env); + ldexec_select_type(node->exec, node, env, pid); exitcode = exec_cleanup(node, env, free_flag); } + // PIPE && !CHILD else { exec->pid = pid; @@ -58,11 +62,10 @@ int ldpre_ast(t_ast_node *ast, t_ld_map_env *env, exec = exec->next; exec->next = node; return (-1); - if (free_flag) - free((node->exec).path); } if (pid == 0) exit(exitcode); + // 3. 정리 return (exitcode); } break; diff --git a/codes/loader/loader_wrapper.c b/codes/loader/loader_wrapper.c index 83db6a5..6dfd2db 100644 --- a/codes/loader/loader_wrapper.c +++ b/codes/loader/loader_wrapper.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* loader_wrapper.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: kyungjle +#+ +:+ +#+ */ +/* By: nicknamemohaji