From 27d6b9034433049fdac3fa5b5c3f7493520fc7d4 Mon Sep 17 00:00:00 2001 From: Ziad Arafat Date: Wed, 6 Oct 2021 11:50:47 -0600 Subject: [PATCH] refactor --- Program2/witharray_shm/witharray_shm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Program2/witharray_shm/witharray_shm.c b/Program2/witharray_shm/witharray_shm.c index 373d2a7..1ebae53 100644 --- a/Program2/witharray_shm/witharray_shm.c +++ b/Program2/witharray_shm/witharray_shm.c @@ -220,7 +220,10 @@ int main(int argc, char const *argv[]) exit(-1); } - shmctl(shmid, IPC_RMID, NULL); + if (shmctl(shmid, IPC_RMID, NULL) < 0) { + perror("Cant delete shared memory"); + exit(1); + } return 0; } @@ -370,7 +373,7 @@ int count3s_parallel_proc() } childcnt++; } - + int pid; while (childcnt > 0) { pid = wait(NULL);