Updated to fully support heredocs with no fd leaks
This commit is contained in:
parent
980cae5597
commit
8146ed2176
4 changed files with 16 additions and 5 deletions
3
Makefile
3
Makefile
|
|
@ -53,7 +53,8 @@ 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 += -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
|
||||
|
|
|
|||
|
|
@ -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,6 +40,7 @@ static t_error _debug_fd(\
|
|||
fds->storage[i].slot.dir.ptr, fds->storage[i].slot.dir.name);
|
||||
i++;
|
||||
}
|
||||
if (exit_code != NULL)
|
||||
*exit_code = 0;
|
||||
return (NO_ERROR);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "me/fs/fs.h"
|
||||
#include "me/mem/mem.h"
|
||||
#include "me/os/os.h"
|
||||
#include "me/printf/printf.h"
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue