Main functions for executing a command.
More...
|
char ** | copy_toks (t_data *data, t_command *command) |
| Creates a copy of all tokens that are in a command structure It's used for forks during exec.
|
|
int | prepare_command (t_data *data) |
| Prepare the command for search_command()
|
|
int | prepare_command_forks (t_data *data) |
|
int | search_command (t_data *data, t_command *command, char **tokens) |
| Search if command is a builtin or not.
|
|
int | not_builtins (t_data *data, t_command *command, char **tokens) |
| Executes commands that are not builtins.
|
|
int | handle_redirections (t_garbage *garbage, t_command *command, int fd_backup[2]) |
| Create and redirect inputs and outputs needed for the command.
|
|
void | reset_redirection (t_garbage *garbage, t_command *command, int fd_backup[2], unsigned char i) |
| Reset redirections by default values Replace the new redirections by stdin and stdout.
|
|
int | needs_to_be_forked (t_command *command) |
| Check if it needs to be forked.
|
|
int | execve_fork (t_data *data, char *path, char **toks, char **envp) |
|
int | handle_redirections_forks (t_garbage *garbage, t_command *command) |
| Create and redirect inputs and outputs needed for the command.
|
|
Main functions for executing a command.
◆ copy_toks()
Creates a copy of all tokens that are in a command structure It's used for forks during exec.
- Parameters
-
data | data structure |
command | command structure |
- Returns
- char** copy of tokens
◆ execve_fork()
int execve_fork |
( |
t_data * | data, |
|
|
char * | path, |
|
|
char ** | toks, |
|
|
char ** | envp ) |
◆ handle_redirections()
Create and redirect inputs and outputs needed for the command.
- Parameters
-
garbage | garbage structure |
command | command structure |
fd_backup | pointer of 2 integers for stdin and stdout backup |
- Returns
- int 0 or positive OK, negative ERROR
◆ handle_redirections_forks()
Create and redirect inputs and outputs needed for the command.
- Parameters
-
garbage | garbage structure |
command | command structure |
- Returns
- int 0 or positive OK, negative ERROR
◆ needs_to_be_forked()
int needs_to_be_forked |
( |
t_command * | command | ) |
|
Check if it needs to be forked.
- Parameters
-
- Returns
- int 0 NO, 1 YES
◆ not_builtins()
Executes commands that are not builtins.
- Parameters
-
data | data structure |
command | command structure |
tokens | array of strings |
- Returns
- int
◆ prepare_command()
int prepare_command |
( |
t_data * | data | ) |
|
◆ prepare_command_forks()
int prepare_command_forks |
( |
t_data * | data | ) |
|
◆ reset_redirection()
void reset_redirection |
( |
t_garbage * | garbage, |
|
|
t_command * | command, |
|
|
int | fd_backup[2], |
|
|
unsigned char | i ) |
Reset redirections by default values Replace the new redirections by stdin and stdout.
- Parameters
-
garbage | garbage structure |
command | command structure |
fd_backup | pointer of 2 integers for stdin and stdout backup |
i | value used for recursion |
◆ search_command()
Search if command is a builtin or not.
- Parameters
-
data | data structure |
command | command structure |
tokens | array of strings |
- Returns
- int 0 if command found, 1 otherwise