-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchildren_proc2.c
More file actions
44 lines (37 loc) · 985 Bytes
/
children_proc2.c
File metadata and controls
44 lines (37 loc) · 985 Bytes
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
44
/*
** EPITECH PROJECT, 2025
** B-PSU-200-LYN-2-1-minishell1-pierre.baud
** File description:
** children_proc2
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
#include "my.h"
void children_proc(char **args, char **envc)
{
redirection_t redir = parse_redirections(args);
handle_input_redirection(redir);
handle_output_redirection(redir);
if (args[0][0] == '/' || args[0][0] == '.')
execve_f(args[0], args, envc);
find_and_execute_command(args, envc);
}
int is_valid_path_length(char *dir, char *cmd)
{
int len_dir = my_strlen(dir);
int len_cmd = my_strlen(cmd);
return (len_dir + len_cmd + 2 >= 1024);
}
void check_path_length(char *dir, char *cmd, char **args, char **envc)
{
char full_path[1024];
if (is_valid_path_length(dir, cmd))
return;
create_full_path(full_path, dir, cmd);
execve_f(full_path, args, envc);
}