From 5fd83771641d15c418f747bd343ba6738d3875f7 Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Sun, 9 May 2021 14:20:58 -0400 Subject: Import macOS userland adv_cmds-176 basic_cmds-55 bootstrap_cmds-116.100.1 developer_cmds-66 diskdev_cmds-667.40.1 doc_cmds-53.60.1 file_cmds-321.40.3 mail_cmds-35 misc_cmds-34 network_cmds-606.40.1 patch_cmds-17 remote_cmds-63 shell_cmds-216.60.1 system_cmds-880.60.2 text_cmds-106 --- file_cmds/ipcs/ipcs.1 | 132 ++++++++++++ file_cmds/ipcs/ipcs.c | 553 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 685 insertions(+) create mode 100644 file_cmds/ipcs/ipcs.1 create mode 100644 file_cmds/ipcs/ipcs.c (limited to 'file_cmds/ipcs') diff --git a/file_cmds/ipcs/ipcs.1 b/file_cmds/ipcs/ipcs.1 new file mode 100644 index 0000000..f0a6df4 --- /dev/null +++ b/file_cmds/ipcs/ipcs.1 @@ -0,0 +1,132 @@ +.\" +.\" Copyright (c) 1994 SigmaSoft, Th. Lockert +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by SigmaSoft, Th. Lockert. +.\" 3. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD: src/usr.bin/ipcs/ipcs.1,v 1.16 2003/05/21 21:07:28 ru Exp $ +.\" +.Dd June 18, 1994 +.Dt "IPCS" 1 +.Os +.Sh NAME +.Nm ipcs +.Nd report System V interprocess communication facilities status +.Sh SYNOPSIS +.Nm ipcs +.Op Fl abcMmopQqSsTt +.Sh DESCRIPTION +The +.Nm ipcs +utility provides information on System V interprocess communication +(IPC) facilities on the system. +.Pp +The options are as follows: +.Bl -tag -width Ds +.It Fl a +Show the maximum amount of information possible when +displaying active semaphores, message queues, +and shared memory segments. +(This is shorthand for specifying the +.Fl b , +.Fl c , +.Fl o , +.Fl p , +and +.Fl t +options.) +.It Fl b +Show the maximum allowed sizes for active semaphores, message queues, +and shared memory segments. The +.Dq maximum allowed size +is the maximum number of bytes in a message on a message queue, +the size of a shared memory segment, +or the number of semaphores in a set of semaphores. +.It Fl c +Show the creator's name and group for active semaphores, message queues, +and shared memory segments. +.It Fl M +Display system information about shared memory. +.It Fl m +Display information about active shared memory segments. +.It Fl o +Show outstanding usage for active message queues, +and shared memory segments. The +.Dq outstanding usage +is the number of messages in a message queue, or the number +of processes attached to a shared memory segment. +.It Fl p +Show the process ID information for active semaphores, message queues, +and shared memory segments. The +.Dq process ID information +is the last process to send a message to or receive a message from +a message queue, +the process that created a semaphore, or the last process to attach +or detach a shared memory segment. +.It Fl Q +Display system information about messages queues. +.It Fl q +Display information about active message queues. +.It Fl S +Display system information about semaphores. +.It Fl s +Display information about active semaphores. +.It Fl T +Display system information about shared memory, message queues +and semaphores. +.It Fl t +Show access times for active semaphores, message queues, +and shared memory segments. The access times is the time +of the last control operation on an IPC object, +the last send or receive of a message, +the last attach or detach of a shared memory segment, +or the last operation on a semaphore. +.El +.Pp +If none of the +.Fl M , +.Fl m , +.Fl Q , +.Fl q , +.Fl S , +or +.Fl s +options are specified, information about all active IPC facilities is +listed. +.Sh RESTRICTIONS +System data structures may change while +.Nm ipcs +is running; the output of +.Nm ipcs +is not guaranteed to be consistent. +.Sh BUGS +This manual page is woefully incomplete, because it does not +at all attempt to explain the information printed by +.Nm ipcs . +.Sh SEE ALSO +.Xr ipcrm 1 +.Sh AUTHORS +.An Thorsten Lockert Aq tholo@sigmasoft.com diff --git a/file_cmds/ipcs/ipcs.c b/file_cmds/ipcs/ipcs.c new file mode 100644 index 0000000..986b229 --- /dev/null +++ b/file_cmds/ipcs/ipcs.c @@ -0,0 +1,553 @@ +/* + * Copyright (c) 1994 SigmaSoft, Th. Lockert + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "sys/types.h" +#include +#include +#include +#include +#include +#include +#include "sys/ipcs.h" +#define KERNEL 1 /* To get new ipc_perm and __(sem|shm|msg)ds_new */ +#include "sys/ipc.h" +#include "sys/sem_internal.h" +#include "sys/shm_internal.h" +#include "sys/msg.h" + + +/* The following is a kludge, until the problem of multiple inclusions + of ipc.h is taken care of. */ +#ifndef IXSEQ_TO_IPCID +#define IXSEQ_TO_IPCID(ix,perm) (((perm._seq) << 16L) | (ix & 0xffff)) +#endif + +static char * +fmt_perm(u_short mode, char write_char) +{ + static char buffer[100]; + + buffer[0] = '-'; + buffer[1] = '-'; + buffer[2] = ((mode & 0400) ? 'r' : '-'); + buffer[3] = ((mode & 0200) ? write_char : '-'); + buffer[4] = '-'; + buffer[5] = ((mode & 0040) ? 'r' : '-'); + buffer[6] = ((mode & 0020) ? write_char : '-'); + buffer[7] = '-'; + buffer[8] = ((mode & 0004) ? 'r' : '-'); + buffer[9] = ((mode & 0002) ? write_char : '-'); + buffer[10] = '-'; + buffer[11] = '\0'; + return (&buffer[0]); +} + +static void +cvt_time(time_t t, char *buf) +{ + struct tm *tm; + + if (t == 0) { + strcpy(buf, "no-entry"); + } else { + tm = localtime(&t); + if (tm != NULL) { + sprintf(buf, "%2d:%02d:%02d", + tm->tm_hour, tm->tm_min, tm->tm_sec); + } + } +} +#define SHMINFO 1 +#define SHMTOTAL 2 +#define MSGINFO 4 +#define MSGTOTAL 8 +#define SEMINFO 16 +#define SEMTOTAL 32 + +#define BIGGEST 1 +#define CREATOR 2 +#define OUTSTANDING 4 +#define PID 8 +#define TIME 16 + +static void +usage(void) +{ + errx(EX_USAGE, "%s","usage: ipcs [-abcmopqstMQST]\n"); +} + +int +main(argc, argv) + int argc; + char *argv[]; +{ + int display = 0; + int option = 0; + int exit_val = 0; + time_t now; + char datestring[100]; + int i; + + while ((i = getopt(argc, argv, "MmQqSsabcoptT")) != -1) + switch (i) { + case 'M': + display = SHMTOTAL; + break; + case 'm': + display |= SHMINFO; + break; + case 'Q': + display = MSGTOTAL; + break; + case 'q': + display |= MSGINFO; + break; + case 'S': + display = SEMTOTAL; + break; + case 's': + display |= SEMINFO; + break; + case 'T': + display = SHMTOTAL | MSGTOTAL | SEMTOTAL; + break; + case 'a': + option |= BIGGEST | CREATOR | OUTSTANDING | PID | TIME; + break; + case 'b': + option |= BIGGEST; + break; + case 'c': + option |= CREATOR; + break; + case 'o': + option |= OUTSTANDING; + break; + case 'p': + option |= PID; + break; + case 't': + option |= TIME; + break; + default: + usage(); + } + if (display == 0) + display = SHMINFO | MSGINFO | SEMINFO; + now = time(0); + struct tm* tm = localtime(&now); + if (tm == NULL) { + now = 0; + tm = localtime(&now); + } + if (0 == strftime(datestring, sizeof(datestring), "%a %b %e %H:%M:%S %Z %Y", tm)) + errx(1, "strftime failed\n"); + printf("IPC status from as of %s\n", datestring); + if ((display & (MSGINFO | MSGTOTAL))) { + if (display & MSGTOTAL) { + struct IPCS_command ic; + struct msginfo msginfo; + size_t ic_size = sizeof(ic); + + ic.ipcs_magic = IPCS_MAGIC; + ic.ipcs_op = IPCS_MSG_CONF; + ic.ipcs_cursor = 0; /* 0 for fw. compat. */ + ic.ipcs_data = &msginfo; + ic.ipcs_datalen = sizeof(msginfo); + + if (sysctlbyname(IPCS_MSG_SYSCTL, &ic, &ic_size, &ic, ic_size)) { + if (errno != EPERM) { + char buffer[1024]; + snprintf(buffer, 1024, "sysctlbyname(IPCS_MSG_SYSCTL, op=CONF, &ic, &%ld) datalen=%d", + sizeof(ic), ic.ipcs_datalen); + perror(buffer); + } else + perror("sysctlbyname IPCS_MSG_SYSCTL"); + } + + printf("msginfo:\n"); + printf("\tmsgmax: %6d\t(max characters in a message)\n", + msginfo.msgmax); + printf("\tmsgmni: %6d\t(# of message queues)\n", + msginfo.msgmni); + printf("\tmsgmnb: %6d\t(max characters in a message queue)\n", + msginfo.msgmnb); + printf("\tmsgtql: %6d\t(max # of messages in system)\n", + msginfo.msgtql); + printf("\tmsgssz: %6d\t(size of a message segment)\n", + msginfo.msgssz); + printf("\tmsgseg: %6d\t(# of message segments in system)\n\n", + msginfo.msgseg); + } + if (display & MSGINFO) { + struct IPCS_command ic; + struct __msqid_ds_new ds; + struct __msqid_ds_new *msqptr = &ds; + size_t ic_size = sizeof(ic); + + printf("T ID KEY MODE OWNER GROUP"); + if (option & CREATOR) + printf(" CREATOR CGROUP"); + if (option & OUTSTANDING) + printf(" CBYTES QNUM"); + if (option & BIGGEST) + printf(" QBYTES"); + if (option & PID) + printf(" LSPID LRPID"); + if (option & TIME) + printf(" STIME RTIME CTIME"); + printf("\nMessage Queues:\n"); + + ic.ipcs_magic = IPCS_MAGIC; + ic.ipcs_op = IPCS_MSG_ITER; + ic.ipcs_cursor = 0; /* start */ + ic.ipcs_datalen = sizeof(*msqptr); + ic.ipcs_data = msqptr; + + memset(msqptr, 0, sizeof(*msqptr)); + + while(!(sysctlbyname(IPCS_MSG_SYSCTL, &ic, &ic_size, &ic, ic_size))) { + ic.ipcs_data = msqptr; + + if (msqptr->msg_qbytes != 0) { + char stime_buf[100], rtime_buf[100], + ctime_buf[100]; + + cvt_time(msqptr->msg_stime, stime_buf); + cvt_time(msqptr->msg_rtime, rtime_buf); + cvt_time(msqptr->msg_ctime, ctime_buf); + + printf("q %6d 0x%08x %s %8s %8s", + IXSEQ_TO_IPCID((ic.ipcs_cursor-1), msqptr->msg_perm), + (int)msqptr->msg_perm._key, + fmt_perm(msqptr->msg_perm.mode, 'w'), + user_from_uid(msqptr->msg_perm.uid, 0), + group_from_gid(msqptr->msg_perm.gid, 0)); + + if (option & CREATOR) + printf(" %8s %8s", + user_from_uid(msqptr->msg_perm.cuid, 0), + group_from_gid(msqptr->msg_perm.cgid, 0)); + + if (option & OUTSTANDING) + printf(" %6lu %6lu", + msqptr->msg_cbytes, + msqptr->msg_qnum); + + if (option & BIGGEST) + printf(" %6lu", + msqptr->msg_qbytes); + + if (option & PID) + printf(" %6d %6d", + msqptr->msg_lspid, + msqptr->msg_lrpid); + + if (option & TIME) + printf(" %s %s %s", + stime_buf, + rtime_buf, + ctime_buf); + + printf("\n"); + } + memset(msqptr, 0, sizeof(*msqptr)); + errno = 0; + } + + if (errno != ENOENT && errno != ERANGE) { + if (errno != EPERM) { + errx(1, "sysctlbyname(IPCS_MSG_SYSCTL, op=ITER, &ic, &%ld) datalen=%d failed:%s\n", + sizeof(ic), ic.ipcs_datalen, strerror(errno)); + } else + errx(1, "sysctlbyname IPCS_MSG_SYSCTL: %s", strerror(errno)); + } + printf("\n"); + } + } else + if (display & (MSGINFO | MSGTOTAL)) { + errx(1, "%s", "SVID messages facility not configured in the system\n"); + } + + if ((display & (SHMINFO | SHMTOTAL))) { + if (display & SHMTOTAL) { + struct IPCS_command ic; + struct shminfo shminfo; + size_t ic_size = sizeof(ic); + + ic.ipcs_magic = IPCS_MAGIC; + ic.ipcs_op = IPCS_SHM_CONF; + ic.ipcs_cursor = 0; /* 0 for fw. compat. */ + ic.ipcs_data = &shminfo; + ic.ipcs_datalen = sizeof(shminfo); + + if (sysctlbyname(IPCS_SHM_SYSCTL, &ic, &ic_size, &ic, ic_size)) { + if (errno != EPERM) { + errx(1, "sysctlbyname(IPCS_SHM_SYSCTL, op=CONF, &ic, &%ld) datalen=%d failed: %s\n", + sizeof(ic), ic.ipcs_datalen, strerror(errno)); + } else + errx(1, "sysctlbyname: %s", strerror(errno)); + } + printf("shminfo:\n"); + printf("\tshmmax: %7lld\t(max shared memory segment size)\n", + shminfo.shmmax); + printf("\tshmmin: %7lld\t(min shared memory segment size)\n", + shminfo.shmmin); + printf("\tshmmni: %7lld\t(max number of shared memory identifiers)\n", + shminfo.shmmni); + printf("\tshmseg: %7lld\t(max shared memory segments per process)\n", + shminfo.shmseg); + printf("\tshmall: %7lld\t(max amount of shared memory in pages)\n\n", + shminfo.shmall); + } + if (display & SHMINFO) { + struct IPCS_command ic; + struct __shmid_ds_new ds; + struct __shmid_ds_new *shmptr = &ds; + size_t ic_size = sizeof(ic); + + printf("T ID KEY MODE OWNER GROUP"); + if (option & CREATOR) + printf(" CREATOR CGROUP"); + if (option & OUTSTANDING) + printf(" NATTCH"); + if (option & BIGGEST) + printf(" SEGSZ"); + if (option & PID) + printf(" CPID LPID"); + if (option & TIME) + printf(" ATIME DTIME CTIME"); + printf("\nShared Memory:\n"); + { /* XXX */ + + ic.ipcs_magic = IPCS_MAGIC; + ic.ipcs_op = IPCS_SHM_ITER; + ic.ipcs_cursor = 0; /* start */ + ic.ipcs_datalen = sizeof(*shmptr); + ic.ipcs_data = shmptr; + memset(shmptr, 0, sizeof(*shmptr)); + + while(!(sysctlbyname(IPCS_SHM_SYSCTL, &ic, &ic_size, &ic, ic_size))) { + ic.ipcs_data = shmptr; /* xnu workaround */ + + if (shmptr->shm_perm.mode & 0x0800) { + char atime_buf[100], dtime_buf[100], + ctime_buf[100]; + + cvt_time(shmptr->shm_atime, atime_buf); + cvt_time(shmptr->shm_dtime, dtime_buf); + cvt_time(shmptr->shm_ctime, ctime_buf); + + printf("m %6d 0x%08x %s %8s %8s", + IXSEQ_TO_IPCID((ic.ipcs_cursor-1), shmptr->shm_perm), + (int)shmptr->shm_perm._key, + fmt_perm(shmptr->shm_perm.mode, 'w'), + user_from_uid(shmptr->shm_perm.uid, 0), + group_from_gid(shmptr->shm_perm.gid, 0)); + + if (option & CREATOR) + printf(" %8s %8s", + user_from_uid(shmptr->shm_perm.cuid, 0), + group_from_gid(shmptr->shm_perm.cgid, 0)); + + if (option & OUTSTANDING) + printf(" %6d", + shmptr->shm_nattch); + + if (option & BIGGEST) + printf(" %6ld", + shmptr->shm_segsz); + + if (option & PID) + printf(" %6d %6d", + shmptr->shm_cpid, + shmptr->shm_lpid); + + if (option & TIME) + printf(" %s %s %s", + atime_buf, + dtime_buf, + ctime_buf); + + printf("\n"); + } + memset(shmptr, 0, sizeof(*shmptr)); + errno = 0; + } + + if (errno != ENOENT && errno != ERANGE) { + if (errno != EPERM) { + errx(1, "sysctlbyname(IPCS_SHM_SYSCTL, op=ITER, &ic, &%ld) datalen=%d failed:%s\n", + sizeof(ic), ic.ipcs_datalen, strerror(errno)); + } else + errx(1, "sysctlbyname: %s", strerror(errno)); + } + } /* XXX */ + printf("\n"); + } + } +else + if (display & (SHMINFO | SHMTOTAL)) { + errx(1, "%s", "SVID shared memory facility not configured in the system\n"); + } + + if ((display & (SEMINFO | SEMTOTAL))) { + if (display & SEMTOTAL) { + struct IPCS_command ic; + struct seminfo seminfo; + size_t ic_size = sizeof(ic); + + ic.ipcs_magic = IPCS_MAGIC; + ic.ipcs_op = IPCS_SEM_CONF; + ic.ipcs_cursor = 0; /* 0 for fw. compat. */ + ic.ipcs_data = &seminfo; + ic.ipcs_datalen = sizeof(seminfo); + + if (sysctlbyname(IPCS_SEM_SYSCTL, &ic, &ic_size, &ic, ic_size)) { + if (errno != EPERM) { + char buffer[1024]; + snprintf(buffer, 1024, "sysctlbyname(IPCS_SEM_SYSCTL, op=CONF, &ic, &%ld) datalen=%d", + sizeof(ic), ic.ipcs_datalen); + perror(buffer); + } else + perror("sysctlbyname IPCS_SEM_SYSCTL/SEM_CONF"); + } + + printf("seminfo:\n"); + printf("\tsemmap: %6d\t(# of entries in semaphore map)\n", + seminfo.semmap); + printf("\tsemmni: %6d\t(# of semaphore identifiers)\n", + seminfo.semmni); + printf("\tsemmns: %6d\t(# of semaphores in system)\n", + seminfo.semmns); + printf("\tsemmnu: %6d\t(# of undo structures in system)\n", + seminfo.semmnu); + printf("\tsemmsl: %6d\t(max # of semaphores per id)\n", + seminfo.semmsl); + printf("\tsemopm: %6d\t(max # of operations per semop call)\n", + seminfo.semopm); + printf("\tsemume: %6d\t(max # of undo entries per process)\n", + seminfo.semume); + printf("\tsemusz: %6d\t(size in bytes of undo structure)\n", + seminfo.semusz); + printf("\tsemvmx: %6d\t(semaphore maximum value)\n", + seminfo.semvmx); + printf("\tsemaem: %6d\t(adjust on exit max value)\n\n", + seminfo.semaem); + } + if (display & SEMINFO) { + struct IPCS_command ic; + struct __semid_ds_new ds; + struct __semid_ds_new *semaptr = &ds; + size_t ic_size = sizeof(ic); + + printf("T ID KEY MODE OWNER GROUP"); + if (option & CREATOR) + printf(" CREATOR CGROUP"); + if (option & BIGGEST) + printf(" NSEMS"); + if (option & TIME) + printf(" OTIME CTIME"); + printf("\nSemaphores:\n"); + + ic.ipcs_magic = IPCS_MAGIC; + ic.ipcs_op = IPCS_SEM_ITER; + ic.ipcs_cursor = 0; /* start */ + ic.ipcs_datalen = sizeof(*semaptr); + ic.ipcs_data = semaptr; + + memset(semaptr, 0, sizeof(*semaptr)); + + while(!(sysctlbyname(IPCS_SEM_SYSCTL, &ic, &ic_size, &ic, ic_size))) { + ic.ipcs_data = semaptr; /* xnu workaround */ + + if ((semaptr->sem_perm.mode & SEM_ALLOC) != 0) { + char ctime_buf[100], otime_buf[100]; + + cvt_time(semaptr->sem_otime, otime_buf); + cvt_time(semaptr->sem_ctime, ctime_buf); + + printf("s %6d 0x%08x %s %8s %8s", + IXSEQ_TO_IPCID((ic.ipcs_cursor-1), semaptr->sem_perm), + (int)semaptr->sem_perm._key, + fmt_perm(semaptr->sem_perm.mode, 'a'), + user_from_uid(semaptr->sem_perm.uid, 0), + group_from_gid(semaptr->sem_perm.gid, 0)); + + if (option & CREATOR) + printf(" %8s %8s", + user_from_uid(semaptr->sem_perm.cuid, 0), + group_from_gid(semaptr->sem_perm.cgid, 0)); + + if (option & BIGGEST) + printf(" %6d", + semaptr->sem_nsems); + + if (option & TIME) + printf(" %s %s", + otime_buf, + ctime_buf); + + printf("\n"); + } + memset(semaptr, 0, sizeof(*semaptr)); + errno = 0; + } + + if (errno != ENOENT && errno != ERANGE) { + if (errno != EPERM) { + errx(1, "sysctlbyname(IPCS_SEM_SYSCTL/ITER, op=ITER, &ic, &%ld) datalen=%d failed: %s\n", + sizeof(ic), ic.ipcs_datalen, strerror(errno)); + } else + errx(1, "sysctlbyname: IPCS_SEM_SYSCTL %s", strerror(errno)); + } + printf("\n"); + } + } else + if (display & (SEMINFO | SEMTOTAL)) { + errx(1, "%s", "SVID semaphores facility not configured in the system\n"); + } + + exit(exit_val); +} -- cgit v1.2.3-56-ge451