Fix piping of built-in functions
authorLilia-42 <nikolovalilianenkova@gmail.com>
Thu, 29 Aug 2024 09:22:25 +0000 (11:22 +0200)
committerLilia-42 <nikolovalilianenkova@gmail.com>
Thu, 29 Aug 2024 09:22:25 +0000 (11:22 +0200)
For piping/redirections of built-in functions the STD_FILENOs
are supposed to be dupped and saved. But the STDIN was dupped
3 times instead of each of STDIN, STDOUT, STDERR being dupped once.

src/execution.c

index ab8e4da3d9c3d661bb3b0ac45a0d24d7e0c53bd5..f6aef757965dd75bea6542888ccc124d11023964 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: lnikolov <lnikolov@student.42prague.com    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/07/21 08:57:54 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/08/27 15:29:43 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/08/29 11:19:20 by lnikolov         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -748,13 +748,13 @@ int       save_std_filenos(int fds[3])
        fds[0] = dup(STDIN_FILENO);
        if (fds[0] < 0)
                return (1);
-       fds[1] = dup(STDIN_FILENO);
+       fds[1] = dup(STDOUT_FILENO);
        if (fds[1] < 0)
        {
                close(fds[0]);
                return (1);
        }
-       fds[2] = dup(STDIN_FILENO);
+       fds[2] = dup(STDERR_FILENO);
        if (fds[2] < 0)
        {
                close(fds[0]);