Minishell
 
Loading...
Searching...
No Matches
Exec Functions

Main functions for executing a command. More...

Functions

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.
 

Detailed Description

Main functions for executing a command.

Function Documentation

◆ copy_toks()

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.

Parameters
datadata structure
commandcommand structure
Returns
char** copy of tokens
Here is the call graph for this function:

◆ execve_fork()

int execve_fork ( t_data * data,
char * path,
char ** toks,
char ** envp )
Here is the call graph for this function:

◆ handle_redirections()

int handle_redirections ( t_garbage * garbage,
t_command * command,
int fd_backup[2] )

Create and redirect inputs and outputs needed for the command.

Parameters
garbagegarbage structure
commandcommand structure
fd_backuppointer of 2 integers for stdin and stdout backup
Returns
int 0 or positive OK, negative ERROR
Here is the call graph for this function:

◆ handle_redirections_forks()

int handle_redirections_forks ( t_garbage * garbage,
t_command * command )

Create and redirect inputs and outputs needed for the command.

Parameters
garbagegarbage structure
commandcommand structure
Returns
int 0 or positive OK, negative ERROR
Here is the call graph for this function:

◆ needs_to_be_forked()

int needs_to_be_forked ( t_command * command)

Check if it needs to be forked.

Parameters
commandcommand structure
Returns
int 0 NO, 1 YES

◆ not_builtins()

int not_builtins ( t_data * data,
t_command * command,
char ** tokens )

Executes commands that are not builtins.

Parameters
datadata structure
commandcommand structure
tokensarray of strings
Returns
int
Here is the call graph for this function:

◆ prepare_command()

int prepare_command ( t_data * data)

Prepare the command for search_command()

Parameters
datadata structure
Returns
int
Here is the call graph for this function:

◆ prepare_command_forks()

int prepare_command_forks ( t_data * data)
Here is the call graph for this function:

◆ 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
garbagegarbage structure
commandcommand structure
fd_backuppointer of 2 integers for stdin and stdout backup
ivalue used for recursion
Here is the call graph for this function:

◆ search_command()

int search_command ( t_data * data,
t_command * command,
char ** tokens )

Search if command is a builtin or not.

Parameters
datadata structure
commandcommand structure
tokensarray of strings
Returns
int 0 if command found, 1 otherwise
Here is the call graph for this function: