diff --git a/src/main.c b/src/main.c index 77c78049273e013e278ad9021fa088531b636a97..1898cbd78d0d032420582429f26a3526a1106f53 100644 --- a/src/main.c +++ b/src/main.c @@ -1,16 +1,25 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <signal.h> #include "commands.h" #include "built_in.h" #include "utils.h" +#include "signal_handlers.h" int main() { char buf[8096]; - + while (1) { + /* buf reset to all '0' */ + memset(buf, 0, 8096); + + /* signal handling */ + signal(SIGINT, (void*)catch_sigint); + signal(SIGTSTP, (void*)catch_sigtstp); + fgets(buf, 8096, stdin); struct single_command commands[512]; diff --git a/src/signal_handlers.c b/src/signal_handlers.c index 4b6fe2e073f327917964b5327b6649f74bcbda1e..aab0ba26dfb6c2d799a5ae8c7a948f714ab8d4cc 100644 --- a/src/signal_handlers.c +++ b/src/signal_handlers.c @@ -1,11 +1,14 @@ #include "signal_handlers.h" +#include <signal.h> void catch_sigint(int signalNo) { - // TODO: File this! + // Ctrl + C + signal(SIGINT, catch_sigint); } void catch_sigtstp(int signalNo) { - // TODO: File this! + // Ctrl + Z + signal(SIGTSTP, catch_sigtstp); }