From 1955fc20d88d420406dd36a231431cd3410d7d53 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Mon, 26 Oct 2020 08:28:06 -0500 Subject: Add error checking --- P2/lib/utils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'P2/lib') diff --git a/P2/lib/utils.c b/P2/lib/utils.c index 5a5a09d..603a699 100644 --- a/P2/lib/utils.c +++ b/P2/lib/utils.c @@ -8,7 +8,7 @@ char *getChunkData(int mapperID) { int mid; //Queue Key key_t key = 10; - mid = msgget(key, 0666); + mid = msgget(key, 0666 | IPC_CREAT); if (mid < 0) { perror("Cannot open queue.\n"); return NULL; @@ -30,6 +30,10 @@ void sendChunkData(char *inputFile, int nMappers) { // open message queue msgid = msgget(key, 0666 | IPC_CREAT); + if (msgid < 0) { + perror("Cannot open queue.\n"); + exit(-1); + } // message.msgText = 1; FILE *fptr = fopen(inputFile, "r"); -- cgit v1.2.3