maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
pipe.h File Reference
#include "shell.h"
#include "tokens.h"
Include dependency graph for pipe.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WAIT_NEXT_COMMAND   1
 

Functions

int builtin_pipe (t_ast *node, t_ms_data *data)
 

Macro Definition Documentation

◆ WAIT_NEXT_COMMAND

#define WAIT_NEXT_COMMAND   1

Definition at line 19 of file pipe.h.

Function Documentation

◆ builtin_pipe()

int builtin_pipe ( t_ast node,
t_ms_data data 
)

Definition at line 46 of file pipe.c.

47{
48 pid_t pid_1;
49 pid_t pid_2;
50 int status_1;
51 int status_2;
52 int setup_result;
53
54 status_1 = 0;
55 status_2 = 0;
56 setup_result = setup_pipe_processes(node, data, &pid_1, &pid_2);
57 if (setup_result == WAIT_NEXT_COMMAND)
58 return (WAIT_NEXT_COMMAND);
59 if (pid_1 > 0 && waitpid(pid_1, &status_1, 0) == -1)
60 return (ft_perror("waitpid"));
61 if (pid_2 > 0)
62 {
63 if (waitpid(pid_2, &status_2, 0) == -1)
64 return (ft_perror("waitpid"));
65 return (WEXITSTATUS(status_2));
66 }
67 return (WEXITSTATUS(status_1));
68}
int ft_perror(char *str)
static int setup_pipe_processes(t_ast *node, t_ms_data *data, pid_t *pid_1, pid_t *pid_2)
Definition pipe.c:25
#define WAIT_NEXT_COMMAND
Definition pipe.h:19

References ft_perror(), setup_pipe_processes(), and WAIT_NEXT_COMMAND.

Referenced by builtin_pipe_test(), and execute_ast().

Here is the call graph for this function:
Here is the caller graph for this function: