-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.c
More file actions
47 lines (37 loc) · 696 Bytes
/
shell.c
File metadata and controls
47 lines (37 loc) · 696 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
45
46
47
#include "shell.h"
/**
* count_env - counts the number of
* environment when the program starts
*
* Return: number of env
*/
int count_env(void)
{
int i = 0;
while (environ[i])
i++;
return (i);
}
/**
* main - initializes shell info
* and starts loop
* @argc: argument count
* @argv: list of arguments
*
* Return: exit stat
*/
int main(int __attribute__((unused)) argc, char **argv)
{
shell_info shellf;
signal(SIGINT, sig_handle);
shellf.name = argv[0];
shellf.command = NULL;
shellf.args = NULL;
shellf.loop_count = 1;
shellf.stat = 0;
shellf.mode = isatty(STDIN_FILENO);
shellf.init_env = count_env();
shellf.pid = getpid();
looper(shellf);
return (0);
}