|
minishell
Minishell Project for École 42
|
Utility Functions for Handling external Commands. More...
#include "minishell.h"
Functions | |
| bool | handle_redirections_single_builtin (t_shell *shell) |
| Handle redirections for a single non-builtin command. | |
| void | saving_stds (int *stdin_cpy, int *stdout_cpy) |
| Save the stdin and stdout file descriptors. | |
| bool | restore_stds (int stdin_cpy, int stdout_cpy) |
| Restore the stdin and stdout file descriptors. | |
Utility Functions for Handling external Commands.
This file contains utility functions to save, restore and set file descriptors while executing an external command. It checks for errors while duplicating/handling signals and sets the correct exit value.
| bool handle_redirections_single_builtin | ( | t_shell * | shell | ) |
Handle redirections for a single non-builtin command.
The handle_redirections_single_builtin function handles redirections for a single non-builtin command. It duplicates the file descriptors needed by the child process and closes back the copy.
| [in,out] | shell | A pointer to the shell struct. |
true if redirections are successfully handled, or false if an error occurs. | bool restore_stds | ( | int | stdin_cpy, |
| int | stdout_cpy | ||
| ) |
Restore the stdin and stdout file descriptors.
The restore_stds function restores the standard input and output file descriptors by duplicating the saved file descriptors back to stdin and stdout. It also handles errors if somehow the restoration fails.
| [in] | stdin_cpy | The duplicated stdin file descriptor. |
| [in] | stdout_cpy | The duplicated stdout file descriptor. |
true if the restoration is successful, or false if an error occurs. | void saving_stds | ( | int * | stdin_cpy, |
| int * | stdout_cpy | ||
| ) |
Save the stdin and stdout file descriptors.
The saving_stds function saves the stdin and stdout file descriptors by duplicating and storing them.
| [out] | stdin_cpy | A pointer to store the duplicated stdin file descriptor. |
| [out] | stdout_cpy | A pointer to store the duplicated stdout file descriptor. |