minishell
Minishell Project for École 42
|
Functions related to handling multiple commands inside a pipeline. More...
#include "minishell.h"
Functions | |
t_info * | init_info (t_shell *shell) |
Initializes the t_info structure. | |
void | wait_pipeline (t_info *info, int number) |
Wait for child processes to finish execution + update the exit code. | |
void | ft_error (t_executor *current, t_info *info) |
Handle errors during command execution and set the exit code accordingly. | |
void | handle_multi (t_shell *shell, t_executor *current) |
Handles the execution of multiple commands. | |
Functions related to handling multiple commands inside a pipeline.
void ft_error | ( | t_executor * | current, |
t_info * | info | ||
) |
Handle errors during command execution and set the exit code accordingly.
This function checks for specific error conditions during command execution (e.g., command not found or permission denied) and sets the exit code accordingly before exiting. Afterwards it frees everything in heap.
current | The current executor representing a command. |
info | Pointer to the t_info structure. |
void handle_multi | ( | t_shell * | shell, |
t_executor * | current | ||
) |
Handles the execution of multiple commands.
This function initializes the t_info structure, executes a sequence of commands represented by the provided nodes of the executor list, and waits for their completion. It also makes a copie of the file descriptor for input redirection and restores it after completion. It handles errors returned from handle_pipeline().
shell | The minishell main data structure. |
current | The head of the executor list representing a command. |
Initializes the t_info structure.
This function allocates memory for the t_info structure, stores process IDs for child processes, a copy of the standard input file descriptor, and a reference to the minishell main data structure.
shell | The minishell main data structure. |
void wait_pipeline | ( | t_info * | info, |
int | number | ||
) |
Wait for child processes to finish execution + update the exit code.
This function waits for the child processes created during command execution to finish and updates the exit code based on their exit status only if the exit status is not 79 (exit without argument). Then it frees the info struct and all it's allocated members.
info | Pointer to the t_info structure. |
number | Number of child processes to wait for. |