|
minishell
Minishell Project for École 42
|
Functions for handling child processes in a multi-command. More...
#include "minishell.h"
Functions | |
| int | handle_redirections_pipeline (int *fildes, t_executor *current, t_info *info) |
| Handles file redirections and file descriptor setup. | |
| void | execute_builtin_child (t_executor *current, t_info *info) |
| Executes a built-in command in a child process and exits. | |
| char * | execute_other_helper (t_executor *current) |
| Helper function to find the executable path. | |
| int | execute_other (t_executor *current, t_info *info) |
| Executes a non-built-in command in a child process using execve. | |
| int | child_handler_multi (int *fildes, t_executor *current, t_info *info) |
| Handles the execution of a child process in a multi-command. | |
Functions for handling child processes in a multi-command.
| int child_handler_multi | ( | int * | fildes, |
| t_executor * | current, | ||
| t_info * | info | ||
| ) |
Handles the execution of a child process in a multi-command.
This function handles the execution of a child process, including setting up file descriptors, executing built-in or non-built-in commands, and managing the child process's exit status.
| fildes | Array of pipe file descriptors. |
| current | The current node of the executor list representing a command. |
| info | Pointer to the t_info structure. |
| void execute_builtin_child | ( | t_executor * | current, |
| t_info * | info | ||
| ) |
Executes a built-in command in a child process and exits.
This function executes a built-in command in a child process, sets the exit code accordingly, frees the heap and then exits the child process.
| current | The current node of the executor list representing a command. |
| info | Pointer to the t_info structure. |
| int execute_other | ( | t_executor * | current, |
| t_info * | info | ||
| ) |
Executes a non-built-in command in a child process using execve.
This function executes a non-built-in command in a child process using the execve() system call and sets the exit code accordingly. If the path is not absolute then it uses execute_other_helper() to get one. Before the execve() call the function transforms the env list into a 2D array in order to pass it to execve().
| current | The current node of the executor list representing a command. |
| info | Pointer to the t_info structure. |
| char * execute_other_helper | ( | t_executor * | current | ) |
Helper function to find the executable path.
This function searches for the executable in the directories listed in the PATH environment variable and returns the full path to the executable.
| current | The current node of the executor list representing a command. |
| int handle_redirections_pipeline | ( | int * | fildes, |
| t_executor * | current, | ||
| t_info * | info | ||
| ) |
Handles file redirections and file descriptor setup.
Sets up file descriptors for a child process in a pipeline, including standard input and output redirection. Manages file descriptors for communication if more commands are in the pipeline.
| fildes | Array of pipe file descriptors. |
| current | The current node of the executor list representing a command. |
| info | Pointer to the t_info structure. |