-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_shell.c
More file actions
42 lines (37 loc) · 1.44 KB
/
Copy pathinit_shell.c
File metadata and controls
42 lines (37 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* init_shell.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rcreer <rcreer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/22 16:46:36 by maakhan #+# #+# */
/* Updated: 2025/01/13 16:23:09 by rcreer ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
t_shl *init_shell(t_path *paths)
{
t_shl *shl;
shl = malloc(sizeof(t_shl));
if (!shl)
print_exit(ERR_MALLOC);
shl->paths = paths;
shl->e_stat = 0;
shl->inside_pipe = FALSE;
shl->head = NULL;
shl->env = NULL;
return (shl);
}
void dup_fds(t_std_fds *std_fds)
{
std_fds->std_in = dup(STDIN_FILENO);
std_fds->std_out = dup(STDOUT_FILENO);
std_fds->std_err = dup(STDERR_FILENO);
}
void reset_std_fds(t_std_fds *std_fds)
{
dup2(std_fds->std_in, STDIN_FILENO);
dup2(std_fds->std_out, STDOUT_FILENO);
dup2(std_fds->std_err, STDERR_FILENO);
}