maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
utils_0.c File Reference
#include "libft.h"
#include <stdio.h>
#include "shell.h"
#include "execute.h"
Include dependency graph for utils_0.c:

Go to the source code of this file.

Functions

int ft_perror (char *str)
 
void close_fds (int in, int out)
 close two file descriptors
 
void handle_temp_fd (t_ms_data *data)
 
void handle_io_fd (t_ms_data *data)
 close temporary input/output file descriptors and reset them to -1
 
void handle_std_io (int *std_io, int std_fileno)
 

Function Documentation

◆ close_fds()

void close_fds ( int  in,
int  out 
)

close two file descriptors

--

  • Parameters
    fdsfile descriptors

Definition at line 28 of file utils_0.c.

29{
30 close(in);
31 close(out);
32}

Referenced by builtin_pipe(), child_process(), execute_child(), and new_process().

Here is the caller graph for this function:

◆ ft_perror()

int ft_perror ( char *  str)

Definition at line 18 of file exit_status_utils.c.

19{
20 perror (str);
21 exit(EXIT_FAILURE);
22}
#define EXIT_FAILURE
Definition exit_status.h:17

◆ handle_io_fd()

void handle_io_fd ( t_ms_data data)

close temporary input/output file descriptors and reset them to -1

--

Parameters
dataminishell structure

Definition at line 39 of file utils_0.c.

40{
41 if (data->std_in != -1 && data->std_out != -1)
42 {
43 close(data->std_in);
44 close(data->std_out);
45 data->std_in = -1;
46 data->std_out = -1;
47 }
48}
int std_out
Definition shell.h:27
int std_in
Definition shell.h:26

References s_ms_data::std_in, and s_ms_data::std_out.

Referenced by process_ast_and_io().

Here is the caller graph for this function:

◆ handle_std_io()

void handle_std_io ( int *  std_io,
int  std_fileno 
)

Definition at line 50 of file utils_0.c.

51{
52 if (*std_io == -1)
53 *std_io = dup(std_fileno);
54 else
55 dup2(*std_io, std_fileno);
56}

Referenced by child_process(), and new_process().

Here is the caller graph for this function:

◆ handle_temp_fd()

void handle_temp_fd ( t_ms_data data)