forget difference between big and small commands - obsolete with vm.
[minix.git] / commands / simple / ipcs.c
blobebb9c6ef09d6eff7ae12ccb64cf75cef9f4d0df3
1 /* Original author unknown, may be "krishna balasub@cis.ohio-state.edu" */
2 /*
4 Modified Sat Oct 9 10:55:28 1993 for 0.99.13
6 Patches from Mike Jagdis (jaggy@purplet.demon.co.uk) applied Wed Feb
7 8 12:12:21 1995 by faith@cs.unc.edu to print numeric uids if no
8 passwd file entry.
10 Patch from arnolds@ifns.de (Heinz-Ado Arnolds) applied Mon Jul 1
11 19:30:41 1996 by janl@math.uio.no to add code missing in case PID:
12 clauses.
14 Patched to display the key field -- hy@picksys.com 12/18/96
16 1999-02-22 Arkadiusz Mi秌iewicz <misiek@pld.ORG.PL>
17 - added Native Language Support
21 #define __USE_MISC
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <errno.h>
26 #include <time.h>
27 #include <pwd.h>
28 #include <grp.h>
29 #include <unistd.h>
30 #include <stdarg.h>
31 #include <sys/types.h>
32 #include <sys/ipc.h>
33 #include <sys/shm.h>
34 #include <sys/sem.h>
36 /* remove _() stuff */
37 #define _(a) a
38 typedef unsigned long ulong;
39 void err(int eval, const char *fmt, ...)
41 va_list ap;
42 va_start(ap, fmt);
43 vfprintf(stderr, fmt, ap);
44 va_end(ap);
45 exit(eval);
48 /*-------------------------------------------------------------------*/
49 /* SHM_DEST and SHM_LOCKED are defined in kernel headers,
50 but inside #ifdef __KERNEL__ ... #endif */
51 #ifndef SHM_DEST
52 /* shm_mode upper byte flags */
53 #define SHM_DEST 01000 /* segment will be destroyed on last detach */
54 #define SHM_LOCKED 02000 /* segment will not be swapped */
55 #endif
57 /* For older kernels the same holds for the defines below */
58 #ifndef MSG_STAT
59 #define MSG_STAT 11
60 #define MSG_INFO 12
61 #endif
63 #ifndef SHM_STAT
64 #define SHM_STAT 13
65 #define SHM_INFO 14
66 struct shm_info {
67 int used_ids;
68 ulong shm_tot; /* total allocated shm */
69 ulong shm_rss; /* total resident shm */
70 ulong shm_swp; /* total swapped shm */
71 ulong swap_attempts;
72 ulong swap_successes;
74 #endif
76 #ifndef SEM_STAT
77 #define SEM_STAT 18
78 #define SEM_INFO 19
79 #endif
81 /* Some versions of libc only define IPC_INFO when __USE_GNU is defined. */
82 #ifndef IPC_INFO
83 #define IPC_INFO 3
84 #endif
85 /*-------------------------------------------------------------------*/
87 /* The last arg of semctl is a union semun, but where is it defined?
88 X/OPEN tells us to define it ourselves, but until recently
89 Linux include files would also define it. */
90 #if defined (__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
91 /* union semun is defined by including <sys/sem.h> */
92 #else
93 /* according to X/OPEN we have to define it ourselves */
94 union semun {
95 int val;
96 struct semid_ds *buf;
97 unsigned short int *array;
98 struct seminfo *__buf;
100 #endif
102 /* X/OPEN (Jan 1987) does not define fields key, seq in struct ipc_perm;
103 libc 4/5 does not mention struct ipc_term at all, but includes
104 <linux/ipc.h>, which defines a struct ipc_perm with such fields.
105 glibc-1.09 has no support for sysv ipc.
106 glibc 2 uses __key, __seq */
107 #if defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
108 #define KEY __key
109 #else
110 #define KEY key
111 #endif
113 #define LIMITS 1
114 #define STATUS 2
115 #define CREATOR 3
116 #define TIME 4
117 #define PID 5
119 void do_shm (char format);
120 void do_sem (char format);
121 void do_msg (char format);
122 void print_shm (int id);
123 void print_msg (int id);
124 void print_sem (int id);
126 static char *progname;
128 static void
129 usage(int rc) {
130 printf (_("usage : %s -asmq -tclup \n"), progname);
131 printf (_("\t%s [-s -m -q] -i id\n"), progname);
132 printf (_("\t%s -h for help.\n"), progname);
133 exit(rc);
136 static void
137 help (int rc) {
138 printf (_("%s provides information on ipc facilities for"
139 " which you have read access.\n"), progname);
140 printf (_("Resource Specification:\n\t-m : shared_mem\n\t-q : messages\n"));
141 printf (_("\t-s : semaphores\n\t-a : all (default)\n"));
142 printf (_("Output Format:\n\t-t : time\n\t-p : pid\n\t-c : creator\n"));
143 printf (_("\t-l : limits\n\t-u : summary\n"));
144 printf (_("-i id [-s -q -m] : details on resource identified by id\n"));
145 usage(rc);
149 main (int argc, char **argv) {
150 int opt, msg = 0, sem = 0, shm = 0, id=0, print=0;
151 char format = 0;
152 char options[] = "atcluphsmqi:";
154 progname = argv[0];
155 while ((opt = getopt (argc, argv, options)) != -1) {
156 switch (opt) {
157 case 'i':
158 id = atoi (optarg);
159 print = 1;
160 break;
161 case 'a':
162 msg = shm = sem = 1;
163 break;
164 case 'q':
165 msg = 1;
166 break;
167 case 's':
168 sem = 1;
169 break;
170 case 'm':
171 shm = 1;
172 break;
173 case 't':
174 format = TIME;
175 break;
176 case 'c':
177 format = CREATOR;
178 break;
179 case 'p':
180 format = PID;
181 break;
182 case 'l':
183 format = LIMITS;
184 break;
185 case 'u':
186 format = STATUS;
187 break;
188 case 'h':
189 help(EXIT_SUCCESS);
190 case '?':
191 usage(EXIT_SUCCESS);
195 if (print) {
196 if (shm)
197 print_shm (id);
198 else if (sem)
199 print_sem (id);
200 else if (msg)
201 print_msg (id);
202 else
203 usage (EXIT_FAILURE);
204 } else {
205 if ( !shm && !msg && !sem)
206 msg = sem = shm = 1;
207 printf ("\n");
209 if (shm) {
210 do_shm (format);
211 printf ("\n");
213 if (sem) {
214 do_sem (format);
215 printf ("\n");
217 if (msg) {
218 do_msg (format);
219 printf ("\n");
222 return EXIT_SUCCESS;
226 static void
227 print_perms (int id, struct ipc_perm *ipcp) {
228 struct passwd *pw;
229 struct group *gr;
231 printf ("%-10d %-10o", id, ipcp->mode & 0777);
233 if ((pw = getpwuid(ipcp->cuid)))
234 printf(" %-10s", pw->pw_name);
235 else
236 printf(" %-10d", ipcp->cuid);
237 if ((gr = getgrgid(ipcp->cgid)))
238 printf(" %-10s", gr->gr_name);
239 else
240 printf(" %-10d", ipcp->cgid);
242 if ((pw = getpwuid(ipcp->uid)))
243 printf(" %-10s", pw->pw_name);
244 else
245 printf(" %-10d", ipcp->uid);
246 if ((gr = getgrgid(ipcp->gid)))
247 printf(" %-10s\n", gr->gr_name);
248 else
249 printf(" %-10d\n", ipcp->gid);
253 void do_shm (char format)
255 int maxid, shmid, id;
256 struct shmid_ds shmseg;
257 struct shm_info shm_info;
258 struct shminfo shminfo;
259 struct ipc_perm *ipcp = &shmseg.shm_perm;
260 struct passwd *pw;
262 maxid = shmctl (0, SHM_INFO, (struct shmid_ds *) (void *) &shm_info);
263 if (maxid < 0 && errno == ENOSYS) {
264 printf (_("kernel not configured for shared memory\n"));
265 return;
268 switch (format) {
269 case LIMITS:
270 printf (_("------ Shared Memory Limits --------\n"));
271 if ((shmctl (0, IPC_INFO, (struct shmid_ds *) (void *) &shminfo)) < 0 )
272 return;
273 /* glibc 2.1.3 and all earlier libc's have ints as fields
274 of struct shminfo; glibc 2.1.91 has unsigned long; ach */
275 printf (_("max number of segments = %lu\n"),
276 (unsigned long) shminfo.shmmni);
277 printf (_("max seg size (kbytes) = %lu\n"),
278 (unsigned long) (shminfo.shmmax >> 10));
279 printf (_("max total shared memory (kbytes) = %lu\n"),
280 getpagesize() / 1024 * (unsigned long) shminfo.shmall);
281 printf (_("min seg size (bytes) = %lu\n"),
282 (unsigned long) shminfo.shmmin);
283 return;
285 case STATUS:
286 printf (_("------ Shared Memory Status --------\n"));
287 printf (_("segments allocated %d\n"), shm_info.used_ids);
288 printf (_("pages allocated %ld\n"), shm_info.shm_tot);
289 printf (_("pages resident %ld\n"), shm_info.shm_rss);
290 printf (_("pages swapped %ld\n"), shm_info.shm_swp);
291 printf (_("Swap performance: %ld attempts\t %ld successes\n"),
292 shm_info.swap_attempts, shm_info.swap_successes);
293 return;
295 case CREATOR:
296 printf (_("------ Shared Memory Segment Creators/Owners --------\n"));
297 printf ("%-10s %-10s %-10s %-10s %-10s %-10s\n",
298 _("shmid"),_("perms"),_("cuid"),_("cgid"),_("uid"),_("gid"));
299 break;
301 case TIME:
302 printf (_("------ Shared Memory Attach/Detach/Change Times --------\n"));
303 printf ("%-10s %-10s %-20s %-20s %-20s\n",
304 _("shmid"),_("owner"),_("attached"),_("detached"),
305 _("changed"));
306 break;
308 case PID:
309 printf (_("------ Shared Memory Creator/Last-op --------\n"));
310 printf ("%-10s %-10s %-10s %-10s\n",
311 _("shmid"),_("owner"),_("cpid"),_("lpid"));
312 break;
314 default:
315 printf (_("------ Shared Memory Segments --------\n"));
316 printf ("%-10s %-10s %-10s %-10s %-10s %-10s %-12s\n",
317 _("key"),_("shmid"),_("owner"),_("perms"),_("bytes"),
318 _("nattch"),_("status"));
319 break;
322 for (id = 0; id <= maxid; id++) {
323 shmid = shmctl (id, SHM_STAT, &shmseg);
324 if (shmid < 0)
325 continue;
326 if (format == CREATOR) {
327 print_perms (shmid, ipcp);
328 continue;
330 pw = getpwuid(ipcp->uid);
331 switch (format) {
332 case TIME:
333 if (pw)
334 printf ("%-10d %-10.10s", shmid, pw->pw_name);
335 else
336 printf ("%-10d %-10d", shmid, ipcp->uid);
337 /* ctime uses static buffer: use separate calls */
338 printf(" %-20.16s", shmseg.shm_atime
339 ? ctime(&shmseg.shm_atime) + 4 : _("Not set"));
340 printf(" %-20.16s", shmseg.shm_dtime
341 ? ctime(&shmseg.shm_dtime) + 4 : _("Not set"));
342 printf(" %-20.16s\n", shmseg.shm_ctime
343 ? ctime(&shmseg.shm_ctime) + 4 : _("Not set"));
344 break;
345 case PID:
346 if (pw)
347 printf ("%-10d %-10.10s", shmid, pw->pw_name);
348 else
349 printf ("%-10d %-10d", shmid, ipcp->uid);
350 printf (" %-10d %-10d\n",
351 shmseg.shm_cpid, shmseg.shm_lpid);
352 break;
354 default:
355 printf("0x%08x ",ipcp->KEY );
356 if (pw)
357 printf ("%-10d %-10.10s", shmid, pw->pw_name);
358 else
359 printf ("%-10d %-10d", shmid, ipcp->uid);
360 printf (" %-10o %-10lu %-10ld %-6s %-6s\n",
361 ipcp->mode & 0777,
363 * earlier: int, Austin has size_t
365 (unsigned long) shmseg.shm_segsz,
367 * glibc-2.1.3 and earlier has unsigned short;
368 * Austin has shmatt_t
370 (long) shmseg.shm_nattch,
371 ipcp->mode & SHM_DEST ? _("dest") : " ",
372 ipcp->mode & SHM_LOCKED ? _("locked") : " ");
373 break;
376 return;
380 void do_sem (char format)
382 int maxid, semid, id;
383 struct semid_ds semary;
384 struct seminfo seminfo;
385 struct ipc_perm *ipcp = &semary.sem_perm;
386 struct passwd *pw;
387 union semun arg;
389 arg.array = (unsigned short *) (void *) &seminfo;
390 maxid = semctl (0, 0, SEM_INFO, arg);
391 if (maxid < 0) {
392 printf (_("kernel not configured for semaphores\n"));
393 return;
396 switch (format) {
397 case LIMITS:
398 printf (_("------ Semaphore Limits --------\n"));
399 arg.array = (unsigned short *) (void *) &seminfo; /* damn union */
400 if ((semctl (0, 0, IPC_INFO, arg)) < 0 )
401 return;
402 printf (_("max number of arrays = %d\n"), seminfo.semmni);
403 printf (_("max semaphores per array = %d\n"), seminfo.semmsl);
404 printf (_("max semaphores system wide = %d\n"), seminfo.semmns);
405 printf (_("max ops per semop call = %d\n"), seminfo.semopm);
406 printf (_("semaphore max value = %d\n"), seminfo.semvmx);
407 return;
409 case STATUS:
410 printf (_("------ Semaphore Status --------\n"));
411 printf (_("used arrays = %d\n"), seminfo.semusz);
412 printf (_("allocated semaphores = %d\n"), seminfo.semaem);
413 return;
415 case CREATOR:
416 printf (_("------ Semaphore Arrays Creators/Owners --------\n"));
417 printf ("%-10s %-10s %-10s %-10s %-10s %-10s\n",
418 _("semid"),_("perms"),_("cuid"),_("cgid"),_("uid"),_("gid"));
419 break;
421 case TIME:
422 printf (_("------ Semaphore Operation/Change Times --------\n"));
423 printf ("%-8s %-10s %-26.24s %-26.24s\n",
424 _("semid"),_("owner"),_("last-op"),_("last-changed"));
425 break;
427 case PID:
428 break;
430 default:
431 printf (_("------ Semaphore Arrays --------\n"));
432 printf ("%-10s %-10s %-10s %-10s %-10s\n",
433 _("key"),_("semid"),_("owner"),_("perms"),_("nsems"));
434 break;
437 for (id = 0; id <= maxid; id++) {
438 arg.buf = (struct semid_ds *) &semary;
439 semid = semctl (id, 0, SEM_STAT, arg);
440 if (semid < 0)
441 continue;
442 if (format == CREATOR) {
443 print_perms (semid, ipcp);
444 continue;
446 pw = getpwuid(ipcp->uid);
447 switch (format) {
448 case TIME:
449 if (pw)
450 printf ("%-8d %-10.10s", semid, pw->pw_name);
451 else
452 printf ("%-8d %-10d", semid, ipcp->uid);
453 printf (" %-26.24s", semary.sem_otime
454 ? ctime(&semary.sem_otime) : _("Not set"));
455 printf (" %-26.24s\n", semary.sem_ctime
456 ? ctime(&semary.sem_ctime) : _("Not set"));
457 break;
458 case PID:
459 break;
461 default:
462 printf("0x%08x ", ipcp->KEY);
463 if (pw)
464 printf ("%-10d %-10.10s", semid, pw->pw_name);
465 else
466 printf ("%-10d %-10d", semid, ipcp->uid);
467 printf (" %-10o %-10ld\n",
468 ipcp->mode & 0777,
470 * glibc-2.1.3 and earlier has unsigned short;
471 * glibc-2.1.91 has variation between
472 * unsigned short and unsigned long
473 * Austin prescribes unsigned short.
475 (long) semary.sem_nsems);
476 break;
482 void do_msg (char format)
484 #if 0
485 int maxid, msqid, id;
486 struct msqid_ds msgque;
487 struct msginfo msginfo;
488 struct ipc_perm *ipcp = &msgque.msg_perm;
489 struct passwd *pw;
491 maxid = msgctl (0, MSG_INFO, (struct msqid_ds *) (void *) &msginfo);
492 if (maxid < 0) {
493 printf (_("kernel not configured for message queues\n"));
494 return;
497 switch (format) {
498 case LIMITS:
499 if ((msgctl (0, IPC_INFO, (struct msqid_ds *) (void *) &msginfo)) < 0 )
500 return;
501 printf (_("------ Messages: Limits --------\n"));
502 printf (_("max queues system wide = %d\n"), msginfo.msgmni);
503 printf (_("max size of message (bytes) = %d\n"), msginfo.msgmax);
504 printf (_("default max size of queue (bytes) = %d\n"), msginfo.msgmnb);
505 return;
507 case STATUS:
508 printf (_("------ Messages: Status --------\n"));
509 printf (_("allocated queues = %d\n"), msginfo.msgpool);
510 printf (_("used headers = %d\n"), msginfo.msgmap);
511 printf (_("used space = %d bytes\n"), msginfo.msgtql);
512 return;
514 case CREATOR:
515 printf (_("------ Message Queues: Creators/Owners --------\n"));
516 printf ("%-10s %-10s %-10s %-10s %-10s %-10s\n",
517 _("msqid"),_("perms"),_("cuid"),_("cgid"),_("uid"),_("gid"));
518 break;
520 case TIME:
521 printf (_("------ Message Queues Send/Recv/Change Times --------\n"));
522 printf ("%-8s %-10s %-20s %-20s %-20s\n",
523 _("msqid"),_("owner"),_("send"),_("recv"),_("change"));
524 break;
526 case PID:
527 printf (_("------ Message Queues PIDs --------\n"));
528 printf ("%-10s %-10s %-10s %-10s\n",
529 _("msqid"),_("owner"),_("lspid"),_("lrpid"));
530 break;
532 default:
533 printf (_("------ Message Queues --------\n"));
534 printf ("%-10s %-10s %-10s %-10s %-12s %-12s\n",
535 _("key"), _("msqid"), _("owner"), _("perms"),
536 _("used-bytes"), _("messages"));
537 break;
540 for (id = 0; id <= maxid; id++) {
541 msqid = msgctl (id, MSG_STAT, &msgque);
542 if (msqid < 0)
543 continue;
544 if (format == CREATOR) {
545 print_perms (msqid, ipcp);
546 continue;
548 pw = getpwuid(ipcp->uid);
549 switch (format) {
550 case TIME:
551 if (pw)
552 printf ("%-8d %-10.10s", msqid, pw->pw_name);
553 else
554 printf ("%-8d %-10d", msqid, ipcp->uid);
555 printf (" %-20.16s", msgque.msg_stime
556 ? ctime(&msgque.msg_stime) + 4 : _("Not set"));
557 printf (" %-20.16s", msgque.msg_rtime
558 ? ctime(&msgque.msg_rtime) + 4 : _("Not set"));
559 printf (" %-20.16s\n", msgque.msg_ctime
560 ? ctime(&msgque.msg_ctime) + 4 : _("Not set"));
561 break;
562 case PID:
563 if (pw)
564 printf ("%-8d %-10.10s", msqid, pw->pw_name);
565 else
566 printf ("%-8d %-10d", msqid, ipcp->uid);
567 printf (" %5d %5d\n",
568 msgque.msg_lspid, msgque.msg_lrpid);
569 break;
571 default:
572 printf( "0x%08x ",ipcp->KEY );
573 if (pw)
574 printf ("%-10d %-10.10s", msqid, pw->pw_name);
575 else
576 printf ("%-10d %-10d", msqid, ipcp->uid);
577 printf (" %-10o %-12ld %-12ld\n",
578 ipcp->mode & 0777,
580 * glibc-2.1.3 and earlier has unsigned short;
581 * glibc-2.1.91 has variation between
582 * unsigned short, unsigned long
583 * Austin has msgqnum_t
585 (long) msgque.msg_cbytes,
586 (long) msgque.msg_qnum);
587 break;
590 return;
591 #endif
595 void print_shm (int shmid)
597 struct shmid_ds shmds;
598 struct ipc_perm *ipcp = &shmds.shm_perm;
600 if (shmctl (shmid, IPC_STAT, &shmds) == -1)
601 err(EXIT_FAILURE, _("shmctl failed"));
603 printf (_("\nShared memory Segment shmid=%d\n"), shmid);
604 printf (_("uid=%d\tgid=%d\tcuid=%d\tcgid=%d\n"),
605 ipcp->uid, ipcp->gid, ipcp->cuid, ipcp->cgid);
606 printf (_("mode=%#o\taccess_perms=%#o\n"),
607 ipcp->mode, ipcp->mode & 0777);
608 printf (_("bytes=%ld\tlpid=%d\tcpid=%d\tnattch=%ld\n"),
609 (long) shmds.shm_segsz, shmds.shm_lpid, shmds.shm_cpid,
610 (long) shmds.shm_nattch);
611 printf (_("att_time=%-26.24s\n"),
612 shmds.shm_atime ? ctime (&shmds.shm_atime) : _("Not set"));
613 printf (_("det_time=%-26.24s\n"),
614 shmds.shm_dtime ? ctime (&shmds.shm_dtime) : _("Not set"));
615 printf (_("change_time=%-26.24s\n"), ctime (&shmds.shm_ctime));
616 printf ("\n");
617 return;
621 void print_msg (int msqid)
623 #if 0
624 struct msqid_ds buf;
625 struct ipc_perm *ipcp = &buf.msg_perm;
627 if (msgctl (msqid, IPC_STAT, &buf) == -1)
628 err(EXIT_FAILURE, _("msgctl failed"));
630 printf (_("\nMessage Queue msqid=%d\n"), msqid);
631 printf (_("uid=%d\tgid=%d\tcuid=%d\tcgid=%d\tmode=%#o\n"),
632 ipcp->uid, ipcp->gid, ipcp->cuid, ipcp->cgid, ipcp->mode);
633 printf (_("cbytes=%ld\tqbytes=%ld\tqnum=%ld\tlspid=%d\tlrpid=%d\n"),
635 * glibc-2.1.3 and earlier has unsigned short;
636 * glibc-2.1.91 has variation between
637 * unsigned short, unsigned long
638 * Austin has msgqnum_t (for msg_qbytes)
640 (long) buf.msg_cbytes, (long) buf.msg_qbytes,
641 (long) buf.msg_qnum, buf.msg_lspid, buf.msg_lrpid);
642 printf (_("send_time=%-26.24s\n"),
643 buf.msg_stime ? ctime (&buf.msg_stime) : _("Not set"));
644 printf (_("rcv_time=%-26.24s\n"),
645 buf.msg_rtime ? ctime (&buf.msg_rtime) : _("Not set"));
646 printf (_("change_time=%-26.24s\n"),
647 buf.msg_ctime ? ctime (&buf.msg_ctime) : _("Not set"));
648 printf ("\n");
649 return;
650 #endif
653 void print_sem (int semid)
655 struct semid_ds semds;
656 struct ipc_perm *ipcp = &semds.sem_perm;
657 union semun arg;
658 int i;
660 arg.buf = &semds;
661 if (semctl (semid, 0, IPC_STAT, arg) < 0)
662 err(EXIT_FAILURE, _("semctl failed"));
664 printf (_("\nSemaphore Array semid=%d\n"), semid);
665 printf (_("uid=%d\t gid=%d\t cuid=%d\t cgid=%d\n"),
666 ipcp->uid, ipcp->gid, ipcp->cuid, ipcp->cgid);
667 printf (_("mode=%#o, access_perms=%#o\n"),
668 ipcp->mode, ipcp->mode & 0777);
669 printf (_("nsems = %ld\n"), (long) semds.sem_nsems);
670 printf (_("otime = %-26.24s\n"),
671 semds.sem_otime ? ctime (&semds.sem_otime) : _("Not set"));
672 printf (_("ctime = %-26.24s\n"), ctime (&semds.sem_ctime));
674 printf ("%-10s %-10s %-10s %-10s %-10s\n",
675 _("semnum"),_("value"),_("ncount"),_("zcount"),_("pid"));
676 arg.val = 0;
677 for (i=0; i< semds.sem_nsems; i++) {
678 int val, ncnt, zcnt, pid;
679 val = semctl (semid, i, GETVAL, arg);
680 ncnt = semctl (semid, i, GETNCNT, arg);
681 zcnt = semctl (semid, i, GETZCNT, arg);
682 pid = semctl (semid, i, GETPID, arg);
683 if (val < 0 || ncnt < 0 || zcnt < 0 || pid < 0)
684 err(EXIT_FAILURE, _("semctl failed"));
686 printf ("%-10d %-10d %-10d %-10d %-10d\n",
687 i, val, ncnt, zcnt, pid);
689 printf ("\n");
690 return;