From d8576826c477f078814103fffe4538cedb6d8895 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Thu, 9 Nov 2017 17:31:44 +0100 Subject: [PATCH] Output an error message when shmat() fails Observed in #1351 with SELinux as the likely culprit. Without the message, the user saw a segfault with no apparent reason --- driver/others/init.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/driver/others/init.c b/driver/others/init.c index 6efd351ac..855dca929 100644 --- a/driver/others/init.c +++ b/driver/others/init.c @@ -78,6 +78,8 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include +#include #include #include #include @@ -659,8 +661,9 @@ static void open_shmem(void) { exit(1); } - if (shmid != -1) common = (shm_t *)shmat(shmid, NULL, 0); - + if (shmid != -1) { + if ( (common = shmat(shmid, NULL, 0)) == (void*)-1) perror ("Attaching shared memory segment"); + } #ifdef DEBUG fprintf(stderr, "Shared Memory id = %x Address = %p\n", shmid, common); #endif