summaryrefslogtreecommitdiffstats
path: root/src/ft_e_lcom.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-23 13:26:08 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-23 13:26:08 +0200
commit8e4d2d074ef0b27a8bc551be4c383e7f9615b820 (patch)
treea82367dff5914abd21e2e98a88caf6b9199cbf1b /src/ft_e_lcom.c
parentIt's working but not quited perfect with >> (diff)
download42-minishell-8e4d2d074ef0b27a8bc551be4c383e7f9615b820.tar.gz
42-minishell-8e4d2d074ef0b27a8bc551be4c383e7f9615b820.tar.bz2
42-minishell-8e4d2d074ef0b27a8bc551be4c383e7f9615b820.tar.xz
42-minishell-8e4d2d074ef0b27a8bc551be4c383e7f9615b820.tar.zst
42-minishell-8e4d2d074ef0b27a8bc551be4c383e7f9615b820.zip
rm qwe
Diffstat (limited to '')
-rw-r--r--src/ft_e_lcom.c18
1 files changed, 9 insertions, 9 deletions
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;
}