]> granicus.if.org Git - procps-ng/commitdiff
pmap: Do not display error if shmctl(..IPC_RMID) returns EINVAL
authorCristian Rodríguez <crrodriguez@opensuse.org>
Thu, 28 Apr 2016 05:22:53 +0000 (02:22 -0300)
committerCraig Small <csmall@enc.com.au>
Thu, 28 Apr 2016 11:36:29 +0000 (21:36 +1000)
The segment may have been destroyed by the kernel automagically
after shmdt(addr)

How to reproduce:

sysctl -w kernel.shm_rmid_forced=1
./pmap 1
shared memory remove: Invalid argument
[..]

pmap.c

diff --git a/pmap.c b/pmap.c
index 0ca95e9c3111756570c7efeda6b48a9514c4cb4f..b2851c5e37516980aed36c4f5abba28322a07880 100644 (file)
--- a/pmap.c
+++ b/pmap.c
@@ -201,7 +201,7 @@ static void discover_shm_minor(void)
                perror(_("shared memory detach"));
 
 out_destroy:
-       if (shmctl(shmid, IPC_RMID, NULL))
+       if (shmctl(shmid, IPC_RMID, NULL) && errno != EINVAL)
                perror(_("shared memory remove"));
 
        return;