From d8e729fdd6cc1b20cb2ab6b4d07dcaad0a87328d Mon Sep 17 00:00:00 2001 From: TriantaTV Date: Sat, 29 Oct 2022 21:21:13 -0500 Subject: [PATCH] Added signal handling and fixed permissions with pishrc --- src/Pish.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Pish.c b/src/Pish.c index 26bcf70..34fce97 100644 --- a/src/Pish.c +++ b/src/Pish.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -27,6 +28,9 @@ void Pish(void) CommandStruct* commandChild = &commandChildObject; char inputString[1000]; // Max 1000 characters int forkPID; + signal(SIGINT, SIG_IGN); + signal(SIGQUIT, SIG_IGN); + signal(SIGTERM, SIG_IGN); ReadPishrc(commandParent, commandChild, inputString); while (1) { @@ -60,7 +64,7 @@ void ReadPishrc(CommandStruct *commandParent, CommandStruct *commandChild, char int *argc = &(commandParent->argc); char* pishLocation = GetHomeDir(); strcat(pishLocation, "/.pishrc"); - int fd = open(pishLocation, O_RDONLY | O_CREAT); + int fd = open(pishLocation, O_RDONLY | O_CREAT, 0644); assert(fd > -1); while (read(fd, buffer, 1) > 0) {