tgrekov-pipex
HIVE pipex May 2024
Loading...
Searching...
No Matches
dispatcher.c File Reference

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* dispatcher.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/23 08:18:15 by tgrekov #+# #+# */
/* Updated: 2024/05/23 05:11:33 by tgrekov ### ########.fr */
/* */
/* ************************************************************************** */

Definition in file dispatcher.c.

#include <stdlib.h>
#include <unistd.h>
#include "../../mandatory/utils/utils.h"
Include dependency graph for dispatcher.c:

Go to the source code of this file.

Functions

void dispatch (char **paths, char *args, char **envp, int *in_out)
 Dispatch child process with argument string args, environment envp, and stdin / stdout in_out[0] / in_out[1].
 
int wait_all (int *pids, int n, int override)
 Wait for first n processes in pids to change state and return the last process's exit code, if it could be resolved, or 1.
 
int dispatcher (int n, char ***str_arrs, int *in_out)
 Dispatch n child processes with argument strings str_arrs[1][i], environment pointer str_arrs[2], where stdin for the first process is in_out[0] and stdout for the last process is in_out[1].
 

Function Documentation

◆ dispatch()

void dispatch ( char **  paths,
char *  args,
char **  envp,
int *  in_out 
)

Dispatch child process with argument string args, environment envp, and stdin / stdout in_out[0] / in_out[1].

Parameters
pathsNull-terminated array of paths with trailing forward slashes to search for the executable name in
argsString of arguments that will be split and passed as argv to the child process
envpEnvironment pointer for the child process
in_outstdin and stdout for the child process

Definition at line 67 of file dispatch.c.

References arr_free(), ft_printf(), and ft_split().

Here is the call graph for this function:

◆ dispatcher()

int dispatcher ( int  n,
char ***  str_arrs,
int *  in_out 
)

Dispatch n child processes with argument strings str_arrs[1][i], environment pointer str_arrs[2], where stdin for the first process is in_out[0] and stdout for the last process is in_out[1].

Parameters
nNumber of processes
str_arrsNull-terminated arrays paths, argv, and envp
in_outstdin for the first process and stdout for the last process
Return values
intExit code of the last process, if available, else 1, or if an error was encountered in the parent process, 1.

Definition at line 85 of file dispatcher.c.

References err().

Here is the call graph for this function:

◆ wait_all()

int wait_all ( int *  pids,
int  n,
int  override 
)

Wait for first n processes in pids to change state and return the last process's exit code, if it could be resolved, or 1.

Parameters
pidsProcess ids to wait on
nNumber of process ids
overrideOverrides return value if non-zero
Return values
intLast process's exit code or 1

Definition at line 31 of file wait_all.c.