minishell
Minishell Project for École 42
Loading...
Searching...
No Matches
handle_pipeline.c File Reference

Functions related to handling multiple commands and their processes. More...

#include "minishell.h"
Include dependency graph for handle_pipeline.c:

Functions

int handle_pipes (int fildes[2])
 Creates a pipe and sets the file descriptors in the given array.
 
pid_t handle_forks (void)
 Creates a child process using fork() and returns the process ID.
 
int parent_handler_multi (int *fildes, t_executor *current)
 Handles the parent process during multi-command execution.
 
int handle_pipeline (int *fildes, t_executor *current, t_info *info, int i)
 Handles the execution of a pipeline of commands.
 

Detailed Description

Functions related to handling multiple commands and their processes.

Function Documentation

◆ handle_forks()

pid_t handle_forks ( void  )

Creates a child process using fork() and returns the process ID.

This function creates a child process using the fork() system call and returns the process ID for the child process.

Returns
Process ID of the child process or -1 on failure.

◆ handle_pipeline()

int handle_pipeline ( int *  fildes,
t_executor current,
t_info info,
int  i 
)

Handles the execution of a pipeline of commands.

This function manages the execution of multiple commands, including creating pipes, forking child processes, calling child and parent handlers and handling error conditions.

Parameters
fildesArray of pipe file descriptors.
currentThe current node of the executor list representing a command.
infoPointer to the t_info structure.
iIndex of the current command/child in the pipeline.
Returns
OKAY on success, FAIL_SYSCALL/FAIL_SYSCALL_PARENT on failure.

◆ handle_pipes()

int handle_pipes ( int  fildes[2])

Creates a pipe and sets the file descriptors in the given array.

This function creates a pipe using the provided file descriptor array and sets the appropriate file descriptors for communication between commands.

Parameters
fildesArray to store pipe file descriptors.
Returns
0 on success, -1 on failure.

◆ parent_handler_multi()

int parent_handler_multi ( int *  fildes,
t_executor current 
)

Handles the parent process during multi-command execution.

This function manages file descriptors for input and output redirection. It manages the pipe for the parent process.

Parameters
fildesArray of pipe file descriptors.
currentThe current node of the executor list representing a command.
Returns
OKAY on success, FAIL_SYSCALL on failure.