]> git.ipfire.org Git - thirdparty/util-linux.git/blob - sys-utils/ipcs.c
352732a3dd16e2c49e5761f0e07cccbb9c1ecc53
[thirdparty/util-linux.git] / sys-utils / ipcs.c
1 /* Original author unknown, may be "krishna balasub@cis.ohio-state.edu" */
2 /*
3 * Modified Sat Oct 9 10:55:28 1993 for 0.99.13
4 *
5 * Patches from Mike Jagdis (jaggy@purplet.demon.co.uk) applied Wed Feb 8
6 * 12:12:21 1995 by faith@cs.unc.edu to print numeric uids if no passwd file
7 * entry.
8 *
9 * Patch from arnolds@ifns.de (Heinz-Ado Arnolds) applied Mon Jul 1 19:30:41
10 * 1996 by janl@math.uio.no to add code missing in case PID: clauses.
11 *
12 * Patched to display the key field -- hy@picksys.com 12/18/96
13 *
14 * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
15 * - added Native Language Support
16 */
17
18 #include <errno.h>
19 #include <features.h>
20 #include <getopt.h>
21
22 #include "c.h"
23 #include "nls.h"
24 #include "closestream.h"
25
26 #include "ipcutils.h"
27
28 enum output_formats {
29 NOTSPECIFIED,
30 LIMITS,
31 STATUS,
32 CREATOR,
33 TIME,
34 PID
35 };
36 enum {
37 OPT_HUMAN = CHAR_MAX + 1
38 };
39
40 static void do_shm (char format, int unit);
41 static void print_shm (int id, int unit);
42 static void do_sem (char format);
43 static void print_sem (int id);
44 static void do_msg (char format, int unit);
45 static void print_msg (int id, int unit);
46
47 /* we read time as int64_t from /proc, so cast... */
48 #define xctime(_x) ctime((time_t *) (_x))
49
50 static void __attribute__ ((__noreturn__)) usage(FILE * out)
51 {
52 fprintf(out, USAGE_HEADER);
53 fprintf(out, " %s [resource ...] [output-format]\n", program_invocation_short_name);
54 fprintf(out, " %s [resource] -i <id>\n", program_invocation_short_name);
55 fprintf(out, USAGE_OPTIONS);
56 fputs(_(" -i, --id <id> print details on resource identified by id\n"), out);
57 fprintf(out, USAGE_HELP);
58 fprintf(out, USAGE_VERSION);
59 fputs(_("\n"), out);
60 fputs(_("Resource options:\n"), out);
61 fputs(_(" -m, --shmems shared memory segments\n"), out);
62 fputs(_(" -q, --queues message queues\n"), out);
63 fputs(_(" -s, --semaphores semaphores\n"), out);
64 fputs(_(" -a, --all all (default)\n"), out);
65 fputs(_("\n"), out);
66 fputs(_("Output format:\n"), out);
67 fputs(_(" -t, --time show attach, detach and change times\n"), out);
68 fputs(_(" -p, --pid show creator and last operations PIDs\n"), out);
69 fputs(_(" -c, --creator show creator and owner\n"), out);
70 fputs(_(" -l, --limits show resource limits\n"), out);
71 fputs(_(" -u, --summary show status summary\n"), out);
72 fputs(_(" --human show sizes in human readable format\n"), out);
73 fputs(_(" -b, --bytes show sizes in bytes\n"), out);
74 fprintf(out, USAGE_MAN_TAIL("ipcs(1)"));
75 exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
76 }
77
78 int main (int argc, char **argv)
79 {
80 int opt, msg = 0, shm = 0, sem = 0, id = 0, specific = 0;
81 char format = NOTSPECIFIED;
82 int unit = IPC_UNIT_DEFAULT;
83 static const struct option longopts[] = {
84 {"id", required_argument, NULL, 'i'},
85 {"queues", no_argument, NULL, 'q'},
86 {"shmems", no_argument, NULL, 'm'},
87 {"semaphores", no_argument, NULL, 's'},
88 {"all", no_argument, NULL, 'a'},
89 {"time", no_argument, NULL, 't'},
90 {"pid", no_argument, NULL, 'p'},
91 {"creator", no_argument, NULL, 'c'},
92 {"limits", no_argument, NULL, 'l'},
93 {"summary", no_argument, NULL, 'u'},
94 {"human", no_argument, NULL, OPT_HUMAN},
95 {"bytes", no_argument, NULL, 'b'},
96 {"version", no_argument, NULL, 'V'},
97 {"help", no_argument, NULL, 'h'},
98 {NULL, 0, NULL, 0}
99 };
100 char options[] = "i:qmsatpclubVh";
101
102 setlocale(LC_ALL, "");
103 bindtextdomain(PACKAGE, LOCALEDIR);
104 textdomain(PACKAGE);
105 atexit(close_stdout);
106
107 while ((opt = getopt_long(argc, argv, options, longopts, NULL)) != -1) {
108 switch (opt) {
109 case 'i':
110 id = atoi (optarg);
111 specific = 1;
112 break;
113 case 'a':
114 msg = shm = sem = 1;
115 break;
116 case 'q':
117 msg = 1;
118 break;
119 case 'm':
120 shm = 1;
121 break;
122 case 's':
123 sem = 1;
124 break;
125 case 't':
126 format = TIME;
127 break;
128 case 'c':
129 format = CREATOR;
130 break;
131 case 'p':
132 format = PID;
133 break;
134 case 'l':
135 format = LIMITS;
136 break;
137 case 'u':
138 format = STATUS;
139 break;
140 case OPT_HUMAN:
141 unit = IPC_UNIT_HUMAN;
142 break;
143 case 'b':
144 unit = IPC_UNIT_BYTES;
145 break;
146 case 'h':
147 usage(stdout);
148 case 'V':
149 printf(UTIL_LINUX_VERSION);
150 return EXIT_SUCCESS;
151 default:
152 usage(stderr);
153 }
154 }
155
156 if (specific && (msg + shm + sem != 1))
157 errx (EXIT_FAILURE,
158 _("when using an ID, a single resource must be specified"));
159 if (specific) {
160 if (msg)
161 print_msg (id, unit);
162 if (shm)
163 print_shm (id, unit);
164 if (sem)
165 print_sem (id);
166 } else {
167 if (!msg && !shm && !sem)
168 msg = shm = sem = 1;
169 printf ("\n");
170 if (msg) {
171 do_msg (format, unit);
172 printf ("\n");
173 }
174 if (shm) {
175 do_shm (format, unit);
176 printf ("\n");
177 }
178 if (sem) {
179 do_sem (format);
180 printf ("\n");
181 }
182 }
183 return EXIT_SUCCESS;
184 }
185
186 static void do_shm (char format, int unit)
187 {
188 struct passwd *pw;
189 struct shm_data *shmds, *shmdsp;
190
191 switch (format) {
192 case LIMITS:
193 {
194 struct ipc_limits lim;
195
196 printf (_("------ Shared Memory Limits --------\n"));
197 if (ipc_shm_get_limits(&lim))
198 return;
199 printf (_("max number of segments = %ju\n"), lim.shmmni);
200 ipc_print_size(unit == IPC_UNIT_DEFAULT ? IPC_UNIT_KB : unit,
201 _("max seg size"), lim.shmmax, "\n", 0);
202 ipc_print_size(unit == IPC_UNIT_DEFAULT ? IPC_UNIT_KB : unit,
203 _("max total shared memory"),
204 lim.shmall * getpagesize(), "\n", 0);
205 ipc_print_size(unit == IPC_UNIT_DEFAULT ? IPC_UNIT_BYTES : unit,
206 _("min seg size"), lim.shmmin, "\n", 0);
207 return;
208 }
209 case STATUS:
210 {
211 int maxid;
212 struct shm_info shm_info;
213
214 maxid = shmctl (0, SHM_INFO, (struct shmid_ds *) &shm_info);
215 if (maxid < 0) {
216 printf (_("kernel not configured for shared memory\n"));
217 return;
218 }
219
220 printf (_("------ Shared Memory Status --------\n"));
221 /*
222 * TRANSLATORS: This output format is maintained for backward
223 * compatibility as ipcs is used in scripts. For consistency
224 * with the rest, the translated form can follow this model:
225 *
226 * "segments allocated = %d\n"
227 * "pages allocated = %ld\n"
228 * "pages resident = %ld\n"
229 * "pages swapped = %ld\n"
230 * "swap performance = %ld attempts, %ld successes\n"
231 */
232 printf (_("segments allocated %d\n"
233 "pages allocated %ld\n"
234 "pages resident %ld\n"
235 "pages swapped %ld\n"
236 "Swap performance: %ld attempts\t %ld successes\n"),
237 shm_info.used_ids,
238 shm_info.shm_tot,
239 shm_info.shm_rss,
240 shm_info.shm_swp,
241 shm_info.swap_attempts, shm_info.swap_successes);
242 return;
243 }
244
245 /*
246 * Headers only
247 */
248 case CREATOR:
249 printf (_("------ Shared Memory Segment Creators/Owners --------\n"));
250 printf ("%-10s %-10s %-10s %-10s %-10s %-10s\n",
251 _("shmid"),_("perms"),_("cuid"),_("cgid"),_("uid"),_("gid"));
252 break;
253
254 case TIME:
255 printf (_("------ Shared Memory Attach/Detach/Change Times --------\n"));
256 printf ("%-10s %-10s %-20s %-20s %-20s\n",
257 _("shmid"),_("owner"),_("attached"),_("detached"),
258 _("changed"));
259 break;
260
261 case PID:
262 printf (_("------ Shared Memory Creator/Last-op PIDs --------\n"));
263 printf ("%-10s %-10s %-10s %-10s\n",
264 _("shmid"),_("owner"),_("cpid"),_("lpid"));
265 break;
266
267 default:
268 printf (_("------ Shared Memory Segments --------\n"));
269 printf ("%-10s %-10s %-10s %-10s %-10s %-10s %-12s\n",
270 _("key"),_("shmid"),_("owner"),_("perms"),
271 unit == IPC_UNIT_HUMAN ? _("size") : _("bytes"),
272 _("nattch"),_("status"));
273 break;
274 }
275
276 /*
277 * Print data
278 */
279 if (ipc_shm_get_info(-1, &shmds) < 1)
280 return;
281 shmdsp = shmds;
282
283 for (shmdsp = shmds; shmdsp->next != NULL; shmdsp = shmdsp->next) {
284 if (format == CREATOR) {
285 ipc_print_perms(stdout, &shmdsp->shm_perm);
286 continue;
287 }
288 pw = getpwuid(shmdsp->shm_perm.uid);
289 switch (format) {
290 case TIME:
291 if (pw)
292 printf ("%-10d %-10.10s", shmdsp->shm_perm.id, pw->pw_name);
293 else
294 printf ("%-10d %-10u", shmdsp->shm_perm.id, shmdsp->shm_perm.uid);
295 /* ctime uses static buffer: use separate calls */
296 printf(" %-20.16s", shmdsp->shm_atim
297 ? xctime(&shmdsp->shm_atim) + 4 : _("Not set"));
298 printf(" %-20.16s", shmdsp->shm_dtim
299 ? xctime(&shmdsp->shm_dtim) + 4 : _("Not set"));
300 printf(" %-20.16s\n", shmdsp->shm_ctim
301 ? xctime(&shmdsp->shm_ctim) + 4 : _("Not set"));
302 break;
303 case PID:
304 if (pw)
305 printf ("%-10d %-10.10s", shmdsp->shm_perm.id, pw->pw_name);
306 else
307 printf ("%-10d %-10u", shmdsp->shm_perm.id, shmdsp->shm_perm.uid);
308 printf (" %-10u %-10u\n",
309 shmdsp->shm_cprid, shmdsp->shm_lprid);
310 break;
311
312 default:
313 printf("0x%08x ", shmdsp->shm_perm.key);
314 if (pw)
315 printf ("%-10d %-10.10s", shmdsp->shm_perm.id, pw->pw_name);
316 else
317 printf ("%-10d %-10u", shmdsp->shm_perm.id, shmdsp->shm_perm.uid);
318 printf (" %-10o ", shmdsp->shm_perm.mode & 0777);
319
320 if (unit == IPC_UNIT_HUMAN)
321 ipc_print_size(unit, NULL, shmdsp->shm_segsz, " ", 6);
322 else
323 ipc_print_size(unit, NULL, shmdsp->shm_segsz, NULL, -10);
324
325 printf (" %-10ju %-6s %-6s\n",
326 shmdsp->shm_nattch,
327 shmdsp->shm_perm.mode & SHM_DEST ? _("dest") : " ",
328 shmdsp->shm_perm.mode & SHM_LOCKED ? _("locked") : " ");
329 break;
330 }
331 }
332
333 ipc_shm_free_info(shmds);
334 return;
335 }
336
337 static void do_sem (char format)
338 {
339 struct passwd *pw;
340 struct sem_data *semds, *semdsp;
341
342 switch (format) {
343 case LIMITS:
344 {
345 struct ipc_limits lim;
346
347 printf (_("------ Semaphore Limits --------\n"));
348 if (ipc_sem_get_limits(&lim))
349 return;
350 printf (_("max number of arrays = %d\n"), lim.semmni);
351 printf (_("max semaphores per array = %d\n"), lim.semmsl);
352 printf (_("max semaphores system wide = %d\n"), lim.semmns);
353 printf (_("max ops per semop call = %d\n"), lim.semopm);
354 printf (_("semaphore max value = %d\n"), lim.semvmx);
355 return;
356 }
357 case STATUS:
358 {
359 struct seminfo seminfo;
360 union semun arg;
361 arg.array = (ushort *) (void *) &seminfo;
362 if (semctl (0, 0, SEM_INFO, arg) < 0) {
363 printf (_("kernel not configured for semaphores\n"));
364 return;
365 }
366 printf (_("------ Semaphore Status --------\n"));
367 printf (_("used arrays = %d\n"), seminfo.semusz);
368 printf (_("allocated semaphores = %d\n"), seminfo.semaem);
369 return;
370 }
371
372 case CREATOR:
373 printf (_("------ Semaphore Arrays Creators/Owners --------\n"));
374 printf ("%-10s %-10s %-10s %-10s %-10s %-10s\n",
375 _("semid"),_("perms"),_("cuid"),_("cgid"),_("uid"),_("gid"));
376 break;
377
378 case TIME:
379 printf (_("------ Semaphore Operation/Change Times --------\n"));
380 printf ("%-8s %-10s %-26.24s %-26.24s\n",
381 _("semid"),_("owner"),_("last-op"),_("last-changed"));
382 break;
383
384 case PID:
385 break;
386
387 default:
388 printf (_("------ Semaphore Arrays --------\n"));
389 printf ("%-10s %-10s %-10s %-10s %-10s\n",
390 _("key"),_("semid"),_("owner"),_("perms"),_("nsems"));
391 break;
392 }
393
394 /*
395 * Print data
396 */
397 if (ipc_sem_get_info(-1, &semds) < 1)
398 return;
399 semdsp = semds;
400
401 for (semdsp = semds; semdsp->next != NULL; semdsp = semdsp->next) {
402 if (format == CREATOR) {
403 ipc_print_perms(stdout, &semdsp->sem_perm);
404 continue;
405 }
406 pw = getpwuid(semdsp->sem_perm.uid);
407 switch (format) {
408 case TIME:
409 if (pw)
410 printf ("%-8d %-10.10s", semdsp->sem_perm.id, pw->pw_name);
411 else
412 printf ("%-8d %-10u", semdsp->sem_perm.id, semdsp->sem_perm.uid);
413 printf (" %-26.24s", semdsp->sem_otime
414 ? xctime(&semdsp->sem_otime) : _("Not set"));
415 printf (" %-26.24s\n", semdsp->sem_ctime
416 ? xctime( &semdsp->sem_ctime) : _("Not set"));
417 break;
418 case PID:
419 break;
420
421 default:
422 printf("0x%08x ", semdsp->sem_perm.key);
423 if (pw)
424 printf ("%-10d %-10.10s", semdsp->sem_perm.id, pw->pw_name);
425 else
426 printf ("%-10d %-10u", semdsp->sem_perm.id, semdsp->sem_perm.uid);
427 printf (" %-10o %-10ju\n",
428 semdsp->sem_perm.mode & 0777,
429 semdsp->sem_nsems);
430 break;
431 }
432 }
433
434 ipc_sem_free_info(semds);
435 return;
436 }
437
438 static void do_msg (char format, int unit)
439 {
440 struct passwd *pw;
441 struct msg_data *msgds, *msgdsp;
442
443 switch (format) {
444 case LIMITS:
445 {
446 struct ipc_limits lim;
447
448 if (ipc_msg_get_limits(&lim))
449 return;
450 printf (_("------ Messages Limits --------\n"));
451 printf (_("max queues system wide = %d\n"), lim.msgmni);
452 ipc_print_size(unit == IPC_UNIT_DEFAULT ? IPC_UNIT_BYTES : unit,
453 _("max size of message"), lim.msgmax, "\n", 0);
454 ipc_print_size(unit == IPC_UNIT_DEFAULT ? IPC_UNIT_BYTES : unit,
455 _("default max size of queue"), lim.msgmnb, "\n", 0);
456 return;
457 }
458 case STATUS:
459 {
460 struct msginfo msginfo;
461 if (msgctl (0, MSG_INFO, (struct msqid_ds *) (void *) &msginfo) < 0) {
462 printf (_("kernel not configured for message queues\n"));
463 return;
464 }
465 printf (_("------ Messages Status --------\n"));
466 printf (_("allocated queues = %d\n"), msginfo.msgpool);
467 printf (_("used headers = %d\n"), msginfo.msgmap);
468 ipc_print_size(unit, _("used space"), msginfo.msgtql,
469 unit == IPC_UNIT_DEFAULT ? _(" bytes\n") : "\n", 0);
470 return;
471 }
472 case CREATOR:
473 printf (_("------ Message Queues Creators/Owners --------\n"));
474 printf ("%-10s %-10s %-10s %-10s %-10s %-10s\n",
475 _("msqid"),_("perms"),_("cuid"),_("cgid"),_("uid"),_("gid"));
476 break;
477
478 case TIME:
479 printf (_("------ Message Queues Send/Recv/Change Times --------\n"));
480 printf ("%-8s %-10s %-20s %-20s %-20s\n",
481 _("msqid"),_("owner"),_("send"),_("recv"),_("change"));
482 break;
483
484 case PID:
485 printf (_("------ Message Queues PIDs --------\n"));
486 printf ("%-10s %-10s %-10s %-10s\n",
487 _("msqid"),_("owner"),_("lspid"),_("lrpid"));
488 break;
489
490 default:
491 printf (_("------ Message Queues --------\n"));
492 printf ("%-10s %-10s %-10s %-10s %-12s %-12s\n",
493 _("key"), _("msqid"), _("owner"), _("perms"),
494 unit == IPC_UNIT_HUMAN ? _("size") : _("used-bytes"),
495 _("messages"));
496 break;
497 }
498
499 /*
500 * Print data
501 */
502 if (ipc_msg_get_info(-1, &msgds) < 1)
503 return;
504 msgdsp = msgds;
505
506 for (msgdsp = msgds; msgdsp->next != NULL; msgdsp = msgdsp->next) {
507 if (format == CREATOR) {
508 ipc_print_perms(stdout, &msgdsp->msg_perm);
509 continue;
510 }
511 pw = getpwuid(msgdsp->msg_perm.uid);
512 switch (format) {
513 case TIME:
514 if (pw)
515 printf ("%-8d %-10.10s", msgdsp->msg_perm.id, pw->pw_name);
516 else
517 printf ("%-8d %-10u", msgdsp->msg_perm.id, msgdsp->msg_perm.uid);
518 printf (" %-20.16s", msgdsp->q_stime
519 ? xctime(&msgdsp->q_stime) + 4 : _("Not set"));
520 printf (" %-20.16s", msgdsp->q_rtime
521 ? xctime(&msgdsp->q_rtime) + 4 : _("Not set"));
522 printf (" %-20.16s\n", msgdsp->q_ctime
523 ? xctime(&msgdsp->q_ctime) + 4 : _("Not set"));
524 break;
525 case PID:
526 if (pw)
527 printf ("%-8d %-10.10s", msgdsp->msg_perm.id, pw->pw_name);
528 else
529 printf ("%-8d %-10u", msgdsp->msg_perm.id, msgdsp->msg_perm.uid);
530 printf (" %5d %5d\n",
531 msgdsp->q_lspid, msgdsp->q_lrpid);
532 break;
533
534 default:
535 printf( "0x%08x ",msgdsp->msg_perm.key );
536 if (pw)
537 printf ("%-10d %-10.10s", msgdsp->msg_perm.id, pw->pw_name);
538 else
539 printf ("%-10d %-10u", msgdsp->msg_perm.id, msgdsp->msg_perm.uid);
540 printf (" %-10o ", msgdsp->msg_perm.mode & 0777);
541
542 if (unit == IPC_UNIT_HUMAN)
543 ipc_print_size(unit, NULL, msgdsp->q_cbytes, " ", 6);
544 else
545 ipc_print_size(unit, NULL, msgdsp->q_cbytes, NULL, -12);
546
547 printf (" %-12ju\n", msgdsp->q_qnum);
548 break;
549 }
550 }
551
552 ipc_msg_free_info(msgds);
553 return;
554 }
555
556 static void print_shm(int shmid, int unit)
557 {
558 struct shm_data *shmdata;
559
560 if (ipc_shm_get_info(shmid, &shmdata) < 1) {
561 warnx(_("id %d not found"), shmid);
562 return;
563 }
564
565 printf(_("\nShared memory Segment shmid=%d\n"), shmid);
566 printf(_("uid=%u\tgid=%u\tcuid=%u\tcgid=%u\n"),
567 shmdata->shm_perm.uid, shmdata->shm_perm.uid,
568 shmdata->shm_perm.cuid, shmdata->shm_perm.cgid);
569 printf(_("mode=%#o\taccess_perms=%#o\n"), shmdata->shm_perm.mode,
570 shmdata->shm_perm.mode & 0777);
571 ipc_print_size(unit, unit == IPC_UNIT_HUMAN ? _("size=") : _("bytes="),
572 shmdata->shm_segsz, "\t", 0);
573 printf(_("lpid=%u\tcpid=%u\tnattch=%jd\n"),
574 shmdata->shm_lprid, shmdata->shm_cprid,
575 shmdata->shm_nattch);
576 printf(_("att_time=%-26.24s\n"),
577 shmdata->shm_atim ? xctime(&(shmdata->shm_atim)) : _("Not set"));
578 printf(_("det_time=%-26.24s\n"),
579 shmdata->shm_dtim ? xctime(&shmdata->shm_dtim) : _("Not set"));
580 printf(_("change_time=%-26.24s\n"), xctime(&shmdata->shm_ctim));
581 printf("\n");
582
583 ipc_shm_free_info(shmdata);
584 }
585
586 void print_msg(int msgid, int unit)
587 {
588 struct msg_data *msgdata;
589
590 if (ipc_msg_get_info(msgid, &msgdata) < 1) {
591 warnx(_("id %d not found"), msgid);
592 return;
593 }
594
595 printf(_("\nMessage Queue msqid=%d\n"), msgid);
596 printf(_("uid=%u\tgid=%u\tcuid=%u\tcgid=%u\tmode=%#o\n"),
597 msgdata->msg_perm.uid, msgdata->msg_perm.uid,
598 msgdata->msg_perm.cuid, msgdata->msg_perm.cgid,
599 msgdata->msg_perm.mode);
600 ipc_print_size(unit, unit == IPC_UNIT_HUMAN ? _("csize=") : _("cbytes="),
601 msgdata->q_cbytes, "\t", 0);
602 ipc_print_size(unit, unit == IPC_UNIT_HUMAN ? _("qsize=") : _("qbytes="),
603 msgdata->q_qbytes, "\t", 0);
604 printf("qnum=%jd\tlspid=%d\tlrpid=%d\n",
605 msgdata->q_qnum,
606 msgdata->q_lspid, msgdata->q_lrpid);
607 printf(_("send_time=%-26.24s\n"),
608 msgdata->q_stime ? xctime(&msgdata->q_stime) : _("Not set"));
609 printf(_("rcv_time=%-26.24s\n"),
610 msgdata->q_rtime ? xctime(&msgdata->q_rtime) : _("Not set"));
611 printf(_("change_time=%-26.24s\n"),
612 msgdata->q_ctime ? xctime(&msgdata->q_ctime) : _("Not set"));
613 printf("\n");
614
615 ipc_msg_free_info(msgdata);
616 }
617
618 static void print_sem(int semid)
619 {
620 struct sem_data *semdata;
621 size_t i;
622
623 if (ipc_sem_get_info(semid, &semdata) < 1) {
624 warnx(_("id %d not found"), semid);
625 return;
626 }
627
628 printf(_("\nSemaphore Array semid=%d\n"), semid);
629 printf(_("uid=%u\t gid=%u\t cuid=%u\t cgid=%u\n"),
630 semdata->sem_perm.uid, semdata->sem_perm.uid,
631 semdata->sem_perm.cuid, semdata->sem_perm.cgid);
632 printf(_("mode=%#o, access_perms=%#o\n"),
633 semdata->sem_perm.mode, semdata->sem_perm.mode & 0777);
634 printf(_("nsems = %ju\n"), semdata->sem_nsems);
635 printf(_("otime = %-26.24s\n"),
636 semdata->sem_otime ? xctime(&semdata->sem_otime) : _("Not set"));
637 printf(_("ctime = %-26.24s\n"), xctime(&semdata->sem_ctime));
638
639 printf("%-10s %-10s %-10s %-10s %-10s\n",
640 _("semnum"), _("value"), _("ncount"), _("zcount"), _("pid"));
641
642 for (i = 0; i < semdata->sem_nsems; i++) {
643 struct sem_elem *e = &semdata->elements[i];
644 printf("%-10zd %-10d %-10d %-10d %-10d\n",
645 i, e->semval, e->ncount, e->zcount, e->pid);
646 }
647 printf("\n");
648 ipc_sem_free_info(semdata);
649 }