2 * Copyright (c) 2015 Elvira Khabirova <lineprinter0@gmail.com>
3 * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 shmctl(id, IPC_RMID, NULL);
41 printf("shmctl\\(%d, (IPC_64\\|)?IPC_RMID, NULL\\) += 0\n", id);
51 id = shmget(IPC_PRIVATE, 1, 0600);
53 perror_msg_and_skip("shmget");
54 printf("shmget\\(IPC_PRIVATE, 1, 0600\\) += %d\n", id);
57 if (shmctl(id, IPC_STAT, &ds))
58 perror_msg_and_skip("shmctl IPC_STAT");
59 printf("shmctl\\(%d, (IPC_64\\|)?IPC_STAT, \\{shm_perm=\\{uid=%u, gid=%u, "
60 "mode=%#o, key=%u, cuid=%u, cgid=%u\\}, shm_segsz=%u, shm_cpid=%u, "
61 "shm_lpid=%u, shm_nattch=%u, shm_atime=%u, shm_dtime=%u, "
62 "shm_ctime=%u\\}\\) += 0\n",
63 id, (unsigned) ds.shm_perm.uid, (unsigned) ds.shm_perm.gid,
64 (unsigned) ds.shm_perm.mode, (unsigned) ds.shm_perm.__key,
65 (unsigned) ds.shm_perm.cuid, (unsigned) ds.shm_perm.cgid,
66 (unsigned) ds.shm_segsz, (unsigned) ds.shm_cpid,
67 (unsigned) ds.shm_lpid, (unsigned) ds.shm_nattch,
68 (unsigned) ds.shm_atime, (unsigned) ds.shm_dtime,
69 (unsigned) ds. shm_ctime);
71 int max = shmctl(0, SHM_INFO, &ds);
73 perror_msg_and_skip("shmctl SHM_INFO");
74 printf("shmctl\\(0, (IPC_64\\|)?SHM_INFO, %p\\) += %d\n", &ds, max);
76 rc = shmctl(id, SHM_STAT, &ds);
79 * In linux < v2.6.24-rc1 the first argument must be
80 * an index in the kernel's internal array.
82 if (-1 != rc || EINVAL != errno)
83 perror_msg_and_skip("shmctl SHM_STAT");
84 printf("shmctl\\(%d, (IPC_64\\|)?SHM_STAT, %p\\) += -1 EINVAL \\(%m\\)\n", id, &ds);
86 printf("shmctl\\(%d, (IPC_64\\|)?SHM_STAT, %p\\) += %d\n", id, &ds, id);