Added signal handling and fixed permissions with pishrc
This commit is contained in:
parent
8bd2940f1a
commit
d8e729fdd6
@ -1,5 +1,6 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -27,6 +28,9 @@ void Pish(void)
|
|||||||
CommandStruct* commandChild = &commandChildObject;
|
CommandStruct* commandChild = &commandChildObject;
|
||||||
char inputString[1000]; // Max 1000 characters
|
char inputString[1000]; // Max 1000 characters
|
||||||
int forkPID;
|
int forkPID;
|
||||||
|
signal(SIGINT, SIG_IGN);
|
||||||
|
signal(SIGQUIT, SIG_IGN);
|
||||||
|
signal(SIGTERM, SIG_IGN);
|
||||||
ReadPishrc(commandParent, commandChild, inputString);
|
ReadPishrc(commandParent, commandChild, inputString);
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@ -60,7 +64,7 @@ void ReadPishrc(CommandStruct *commandParent, CommandStruct *commandChild, char
|
|||||||
int *argc = &(commandParent->argc);
|
int *argc = &(commandParent->argc);
|
||||||
char* pishLocation = GetHomeDir();
|
char* pishLocation = GetHomeDir();
|
||||||
strcat(pishLocation, "/.pishrc");
|
strcat(pishLocation, "/.pishrc");
|
||||||
int fd = open(pishLocation, O_RDONLY | O_CREAT);
|
int fd = open(pishLocation, O_RDONLY | O_CREAT, 0644);
|
||||||
assert(fd > -1);
|
assert(fd > -1);
|
||||||
while (read(fd, buffer, 1) > 0)
|
while (read(fd, buffer, 1) > 0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user