MiniDevil
As beautiful as a shell
Pipe execution: forks and handles left / right sides of pipes. More...
#include <sys/wait.h>#include <signal.h>#include <stdio.h>#include "executor.h"#include "libft.h"#include "ast.h"#include "env.h"#include "signals.h"#include "get_next_line.h"
Include dependency graph for executor_pipe.c:Pipe execution: forks and handles left / right sides of pipes.
Definition in file executor_pipe.c.
Functions | |
| void | exec_left_pipe_child (t_ast *left, int pipe_fd[2], t_shell *shell) |
| Execute the left side of a pipe in a child process. More... | |
| void | exec_right_pipe_child (t_ast *right, int pipe_fd[2], t_shell *shell) |
| Execute the right side of a pipe in a child process. More... | |
| static int | wait_for_pipe_children (pid_t left_pid, pid_t right_pid) |
| Wait for both pipe children and return the right one's status. More... | |
| int | handle_pipe (t_ast *node, t_shell *shell) |
| Execute a pipe node by forking left and right children. More... | |
Execute the left side of a pipe in a child process.
Closes the read end of the pipe and redirects STDOUT to the write end
| left | Left AST subtree to execute |
| pipe_fd | Pipe file descriptors: [read-—write] |
| shell | Shell context |
Definition at line 33 of file executor_pipe.c.
References t_shell::current_ast, t_shell::current_input, t_shell::env, executor(), free_ast(), free_env_list(), t_shell::is_child, and reset_child_signals().
Referenced by handle_pipe().
Here is the call graph for this function:
Here is the caller graph for this function:Execute the right side of a pipe in a child process.
Closes the write end of the pipe and redirects STDIN to the read end
| right | Right AST subtree to execute |
| pipe_fd | Pipe file descriptors: [read-—write] |
| shell | Shell context |
Definition at line 60 of file executor_pipe.c.
References t_shell::current_ast, t_shell::current_input, t_shell::env, executor(), free_ast(), free_env_list(), t_shell::is_child, and reset_child_signals().
Referenced by handle_pipe().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Wait for both pipe children and return the right one's status.
Handles signal deaths (SIGINT = newline, SIGQUIT = core dump message)
| left_pid | PID of the left pipe child |
| right_pid | PID of the right pipe child |
Definition at line 86 of file executor_pipe.c.
Referenced by handle_pipe().
Here is the caller graph for this function:Execute a pipe node by forking left and right children.
Creates a pipe, forks 2 children:
| node | AST pipe node with binary.left and binary.right subtrees |
| shell | Shell context |
Definition at line 119 of file executor_pipe.c.
References t_ast_data::binary, t_ast::data, exec_left_pipe_child(), exec_right_pipe_child(), t_binary_node::left, pipe_fork_error(), t_binary_node::right, and wait_for_pipe_children().
Referenced by executor().
Here is the call graph for this function:
Here is the caller graph for this function: