maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
utils_0.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* utils_0.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: dmdemirk <dmdemirk@student.42london.c +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2024/06/04 17:32:22 by dmdemirk #+# #+# */
9/* Updated: 2024/09/09 13:01:32 by dmdemirk ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "libft.h"
14#include <stdio.h>
15#include "shell.h"
16#include "execute.h"
17
18int ft_perror(char *str);
19void close_fds(int in, int out);
21
28void close_fds(int in, int out)
29{
30 close(in);
31 close(out);
32}
33
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}
49
50void handle_std_io(int *std_io, int std_fileno)
51{
52 if (*std_io == -1)
53 *std_io = dup(std_fileno);
54 else
55 dup2(*std_io, std_fileno);
56}
int std_out
Definition shell.h:27
int std_in
Definition shell.h:26
void handle_std_io(int *std_io, int std_fileno)
Definition utils_0.c:50
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
Definition utils_0.c:39
void close_fds(int in, int out)
close two file descriptors
Definition utils_0.c:28
int ft_perror(char *str)