-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_msg.c
37 lines (34 loc) · 1.32 KB
/
error_msg.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error_msg.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kmatjuhi <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/07 14:11:11 by kmatjuhi #+# #+# */
/* Updated: 2024/03/07 15:51:09 by kmatjuhi ### ########.fr */
/* */
/* ************************************************************************** */
#include "pipex.h"
void error_msg(char *str, int *fd, int code, pid_t pid)
{
close(fd[0]);
close(fd[1]);
ft_putstr_fd("pipex: ", 2);
ft_putstr_fd(str, 2);
ft_putstr_fd(": ", 2);
perror("");
if (code == 2)
waitpid(pid, NULL, 0);
exit(code);
}
void custom_msg(char *cmd, char *str, int *fd, char **args)
{
close(fd[0]);
close(fd[1]);
ft_putstr_fd("pipex: ", 2);
ft_putstr_fd(cmd, 2);
ft_putstr_fd(str, 2);
ft_free_arr(args);
exit(EXIT_FAILURE);
}