-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpwd.c
31 lines (28 loc) · 1.18 KB
/
pwd.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pwd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ikgonzal <ikgonzal@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/24 07:25:21 by ikgonzal #+# #+# */
/* Updated: 2022/04/15 20:53:29 by ikgonzal ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
#include <limits.h>
int ft_pwd(t_proc *proc, int child, int fd)
{
size_t cnt;
char str[PATH_MAX];
if (proc->process_count != 1)
fd = 1;
if (getcwd(str, PATH_MAX) == NULL)
return (1);
cnt = ft_strlen(str);
write(fd, str, cnt);
write(fd, "\n", 1);
if (child)
exit (0);
return (0);
}