-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_initprocess.c
More file actions
43 lines (40 loc) · 1.38 KB
/
ft_initprocess.c
File metadata and controls
43 lines (40 loc) · 1.38 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
43
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_initprocess.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: makbulut <makbulut@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/25 23:31:39 by makbulut #+# #+# */
/* Updated: 2022/08/21 13:23:41 by makbulut ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
#include <stdio.h>
#include "minishell.h"
#include "42-Libft/libft.h"
int ft_initprocess(t_command *cmd, char *cmdpath)
{
pid_t pid;
int execreturn;
pid = fork();
if (pid == 0)
{
ft_clearsignals();
if (!ft_open_reds(cmd))
{
g_mini->exitflag = 1;
exit(-1);
}
ft_connectio(cmd);
ft_closepipes();
execreturn = execve(cmdpath, cmd->arguments, g_mini->env);
if (execreturn != 0)
{
ft_puterrno_msg(cmd->command);
g_mini->exitflag = 1;
exit(-1);
}
}
return (pid);
}