summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile2
-rw-r--r--src/ft_e_lcom.c18
2 files changed, 10 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 4cebc18..286efe5 100644
--- a/Makefile
+++ b/Makefile
@@ -97,7 +97,7 @@ clean:
#------------------------------------------------------------------------------#
fclean: clean
@$(MAKE) --no-print-directory -C ${LFT_DIR} fclean
- ${RM} ${NAME} ${NAME}.core ${NAME}.dSYM/ ${HISTFILE}
+ ${RM} ${NAME} ${NAME}.core ${NAME}.dSYM/ ${HISTFILE} qwe
#------------------------------------------------------------------------------#
re: fclean all
#------------------------------------------------------------------------------#
diff --git a/src/ft_e_lcom.c b/src/ft_e_lcom.c
index dab8f95..677a2a1 100644
--- a/src/ft_e_lcom.c
+++ b/src/ft_e_lcom.c
@@ -52,25 +52,25 @@ uint8_t
{
if ((pid = fork()) == 0)
{
- fd = 0;
- ft_printf("%hhd\n", ptr->redir);
+ ft_printf("[%hhd] [%s]\n", ptr->redir, ptr->rdrpath);
if (ptr->redir == 1)
{
- if ((fd = open(ptr->rdrpath, O_CREAT | O_RDWR, 0644)))
+ if ((fd = open(ptr->rdrpath, O_CREAT | O_TRUNC | O_WRONLY, 0644)))
{
/* TODO: handle err with errno */
}
- /* TODO: erase file and write */
+ dup2(fd, STDOUT_FILENO);
+ close(fd);
}
else if (ptr->redir == 2)
{
- if ((fd = open(ptr->rdrpath, O_CREAT | O_RDWR | O_APPEND, 0644)))
+ if ((fd = open(ptr->rdrpath, O_CREAT | O_APPEND | O_WRONLY, 0644)))
{
/* TODO: handle err with errno */
}
+ dup2(fd, STDOUT_FILENO);
+ close(fd);
}
- dup2(fd, STDOUT_FILENO);
- close(fd);
msh->ret = msh->bu_ptr[bu_id](ptr->args, msh);
exit(msh->ret);
}
@@ -80,9 +80,9 @@ uint8_t
}
else
{
- while (!(wait(&status) == pid))
+ while (wait(&status) != pid)
{
- /* TODO: fix this syntax */
+ /* TODO: fix this unnormed syntax */
}
msh->ret = status;
}