-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathomsh.c
49 lines (43 loc) · 902 Bytes
/
omsh.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
38
39
40
41
42
43
44
45
46
47
48
49
#include "main.h"
/**
* sigIntHandle - handle interrupt signal
* @num: signal number
*
* Return: Nothing
*/
void sigIntHandle(int num)
{
(void) num;
write(STDOUT_FILENO, "\n$ ", 3);
fflush(stdout);
}
/**
* main - program that prints all the command line arguments passed to it
* without using ac
* @ac: count of the command line arguments passed to the program
* @av: NULL terminated array of strings
*
* Return: returns 0 for successful execution
*/
int main(__attribute__((unused)) int ac, char **av)
{
int mode;
errno = 0;
/* ignore Ctrl+C interrupt */
mode = isatty(STDIN_FILENO);
/* mode switching */
if (mode == 0 && errno == ENOTTY)
{
/* Non-interactive mode */
runNonInteractive(av[0]);
}
else
{
/* interactive mode */
/* make a function name interactiveLoop */
signal(SIGINT, sigIntHandle);
runInteractive(av[0]);
_putchar('\n');
}
return (0);
}