diff --git a/Makefile b/Makefile index b800f13d..0a7e9c3e 100644 --- a/Makefile +++ b/Makefile @@ -51,9 +51,10 @@ CFLAGS_ADDITIONAL += -O0 CFLAGS_ADDITIONAL += -Wno-cpp -Wno-type-limits -Wno-unused-command-line-argument CFLAGS_ADDITIONAL += -gcolumn-info -g3 CFLAGS_ADDITIONAL += '-DERROR=((void)printf("ERROR HERE: " __FILE__ ":%d in %s\n", __LINE__, __func__), 1)' -#CFLAGS_ADDITIONAL += -O2 +# CFLAGS_ADDITIONAL += -O2 # CFLAGS_ADDITIONAL += -fuse-ld=gold -Wl,--print-symbol-counts -Wl,/tmp/symbols_count.log -CFLAGS_ADDITIONAL += -fuse-ld=lld -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,-O3 -Wl,--allow-multiple-definition +# CFLAGS_ADDITIONAL += -fuse-ld=lld -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,-O3 -Wl,--allow-multiple +# CFLAGS_ADDITIONAL += -I$(shell realpath ./includes) -I$(shell realpath ./output/include) export CFLAGS_ADDITIONAL export CC diff --git a/exec/src/builtins/_debug.c b/exec/src/builtins/_debug.c index c8038553..693cdd67 100644 --- a/exec/src/builtins/_debug.c +++ b/exec/src/builtins/_debug.c @@ -19,7 +19,7 @@ #define USG "Usage:\n - print_fd: print the opened file descritors informations" -static t_error _debug_fd(\ +t_error _debug_fd(\ t_state *state, t_builtin_spawn_info info, t_i32 *exit_code) { const t_fd_array *fds = get_fd_arrays(); @@ -40,7 +40,8 @@ static t_error _debug_fd(\ fds->storage[i].slot.dir.ptr, fds->storage[i].slot.dir.name); i++; } - *exit_code = 0; + if (exit_code != NULL) + *exit_code = 0; return (NO_ERROR); } diff --git a/stdme/src/os/process.c b/stdme/src/os/process.c index ccd21585..0fa5598b 100644 --- a/stdme/src/os/process.c +++ b/stdme/src/os/process.c @@ -10,6 +10,7 @@ /* */ /* ************************************************************************** */ +#include "me/fs/fs.h" #include "me/mem/mem.h" #include "me/os/os.h" #include "me/printf/printf.h" @@ -42,7 +43,7 @@ t_error spawn_process_exec(t_spawn_info info, t_process *process) close_fd(info.stdout.fd.fd); close_fd(info.stderr.fd.fd); vec_str_push(&info.arguments, NULL); - vec_str_push(&info.environement, NULL); + vec_str_push(&info.environement, NULL); execve(info.binary_path, info.arguments.buffer, info.environement.buffer); return (ERROR); } diff --git a/stdme/src/os/process_redirection.c b/stdme/src/os/process_redirection.c index 3915b090..aba9b206 100644 --- a/stdme/src/os/process_redirection.c +++ b/stdme/src/os/process_redirection.c @@ -37,20 +37,28 @@ t_error _handle_redirections_inherited(t_spawn_info *info, t_process *process) t_error _handle_redirections_fds(t_spawn_info *info, t_process *process) { + t_fd *tmp; + if (info->stdin.tag == R_FD) { + tmp = info->stdin.fd.fd; info->stdin = fd(dup_fd(info->stdin.fd.fd)); process->stdin = dup_fd(info->stdin.fd.fd); + close_fd(tmp); } if (info->stdout.tag == R_FD) { + tmp = info->stdin.fd.fd; info->stdout = fd(dup_fd(info->stdout.fd.fd)); process->stdout = dup_fd(info->stdout.fd.fd); + close_fd(tmp); } if (info->stderr.tag == R_FD) { + tmp = info->stdin.fd.fd; info->stderr = fd(dup_fd(info->stderr.fd.fd)); process->stderr = dup_fd(info->stderr.fd.fd); + close_fd(tmp); } return (NO_ERROR); }