Index: head/sys/sys/msg.h =================================================================== --- head/sys/sys/msg.h (revision 286087) +++ head/sys/sys/msg.h (revision 286088) @@ -1,181 +1,182 @@ /* $FreeBSD$ */ /* $NetBSD: msg.h,v 1.4 1994/06/29 06:44:43 cgd Exp $ */ /*- * SVID compatible msg.h file * * Author: Daniel Boulet * * Copyright 1993 Daniel Boulet and RTMX Inc. * * This system call was implemented by Daniel Boulet under contract from RTMX. * * Redistribution and use in source forms, with and without modification, * are permitted provided that this entire comment appears intact. * * Redistribution in binary form may occur without any restrictions. * Obviously, it would be nice if you gave credit where credit is due * but requiring it would be too onerous. * * This software is provided ``AS IS'' without any warranties of any kind. */ #ifndef _SYS_MSG_H_ #define _SYS_MSG_H_ #include #include #include /* * The MSG_NOERROR identifier value, the msqid_ds struct and the msg struct * are as defined by the SV API Intel 386 Processor Supplement. */ #define MSG_NOERROR 010000 /* don't complain about too long msgs */ typedef unsigned long msglen_t; typedef unsigned long msgqnum_t; #ifndef _PID_T_DECLARED typedef __pid_t pid_t; #define _PID_T_DECLARED #endif #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif #ifndef _SSIZE_T_DECLARED typedef __ssize_t ssize_t; #define _SSIZE_T_DECLARED #endif #ifndef _TIME_T_DECLARED typedef __time_t time_t; #define _TIME_T_DECLARED #endif #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \ defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7) struct msqid_ds_old { struct ipc_perm_old msg_perm; /* msg queue permission bits */ struct msg *msg_first; /* first message in the queue */ struct msg *msg_last; /* last message in the queue */ msglen_t msg_cbytes; /* number of bytes in use on the queue */ msgqnum_t msg_qnum; /* number of msgs in the queue */ msglen_t msg_qbytes; /* max # of bytes on the queue */ pid_t msg_lspid; /* pid of last msgsnd() */ pid_t msg_lrpid; /* pid of last msgrcv() */ time_t msg_stime; /* time of last msgsnd() */ long msg_pad1; time_t msg_rtime; /* time of last msgrcv() */ long msg_pad2; time_t msg_ctime; /* time of last msgctl() */ long msg_pad3; long msg_pad4[4]; }; #endif /* * XXX there seems to be no prefix reserved for this header, so the name * "msg" in "struct msg" and the names of all of the nonstandard members * (mainly "msg_pad*) are namespace pollution. */ struct msqid_ds { struct ipc_perm msg_perm; /* msg queue permission bits */ struct msg *msg_first; /* first message in the queue */ struct msg *msg_last; /* last message in the queue */ msglen_t msg_cbytes; /* number of bytes in use on the queue */ msgqnum_t msg_qnum; /* number of msgs in the queue */ msglen_t msg_qbytes; /* max # of bytes on the queue */ pid_t msg_lspid; /* pid of last msgsnd() */ pid_t msg_lrpid; /* pid of last msgrcv() */ time_t msg_stime; /* time of last msgsnd() */ time_t msg_rtime; /* time of last msgrcv() */ time_t msg_ctime; /* time of last msgctl() */ }; #if __BSD_VISIBLE /* * Structure describing a message. The SVID doesn't suggest any * particular name for this structure. There is a reference in the * msgop man page that reads "The structure mymsg is an example of what * this user defined buffer might look like, and includes the following * members:". This sentence is followed by two lines equivalent * to the mtype and mtext field declarations below. It isn't clear * if "mymsg" refers to the name of the structure type or the name of an * instance of the structure... */ struct mymsg { long mtype; /* message type (+ve integer) */ char mtext[1]; /* message body */ }; #endif #ifdef _KERNEL struct msg { struct msg *msg_next; /* next msg in the chain */ long msg_type; /* type of this message */ /* >0 -> type of this message */ /* 0 -> free header */ u_short msg_ts; /* size of this message */ short msg_spot; /* location of start of msg in buffer */ struct label *label; /* MAC Framework label */ }; /* * Based on the configuration parameters described in an SVR2 (yes, two) * config(1m) man page. * * Each message is broken up and stored in segments that are msgssz bytes * long. For efficiency reasons, this should be a power of two. Also, * it doesn't make sense if it is less than 8 or greater than about 256. * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of * two between 8 and 1024 inclusive (and panic's if it isn't). */ struct msginfo { int msgmax, /* max chars in a message */ msgmni, /* max message queue identifiers */ msgmnb, /* max chars in a queue */ msgtql, /* max messages in system */ msgssz, /* size of a message segment (see notes above) */ msgseg; /* number of message segments */ }; extern struct msginfo msginfo; /* * Kernel wrapper for the user-level structure. */ struct msqid_kernel { /* * Data structure exposed to user space. */ struct msqid_ds u; /* * Kernel-private components of the message queue. */ struct label *label; /* MAC label */ struct ucred *cred; /* creator's credentials */ }; -#else /* !_KERNEL */ +#endif /* _KERNEL */ +#if !defined(_KERNEL) || defined(_WANT_MSG_PROTOTYPES) __BEGIN_DECLS int msgctl(int, int, struct msqid_ds *); int msgget(key_t, int); /* XXX return value should be ssize_t. */ int msgrcv(int, void *, size_t, long, int); int msgsnd(int, const void *, size_t, int); #if __BSD_VISIBLE int msgsys(int, ...); #endif __END_DECLS -#endif /* _KERNEL */ +#endif /* !_KERNEL || _WANT_MSG_PROTOTYPES */ #endif /* !_SYS_MSG_H_ */ Index: head/sys/sys/sem.h =================================================================== --- head/sys/sys/sem.h (revision 286087) +++ head/sys/sys/sem.h (revision 286088) @@ -1,153 +1,154 @@ /* $FreeBSD$ */ /* $NetBSD: sem.h,v 1.5 1994/06/29 06:45:15 cgd Exp $ */ /* * SVID compatible sem.h file * * Author: Daniel Boulet */ #ifndef _SYS_SEM_H_ #define _SYS_SEM_H_ #include #ifndef _PID_T_DECLARED typedef __pid_t pid_t; #define _PID_T_DECLARED #endif #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif #ifndef _TIME_T_DECLARED typedef __time_t time_t; #define _TIME_T_DECLARED #endif #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \ defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7) struct semid_ds_old { struct ipc_perm_old sem_perm; /* operation permission struct */ struct sem *sem_base; /* pointer to first semaphore in set */ unsigned short sem_nsems; /* number of sems in set */ time_t sem_otime; /* last operation time */ long sem_pad1; /* SVABI/386 says I need this here */ time_t sem_ctime; /* last change time */ /* Times measured in secs since */ /* 00:00:00 UTC, Jan. 1, 1970, without leap seconds */ long sem_pad2; /* SVABI/386 says I need this here */ long sem_pad3[4]; /* SVABI/386 says I need this here */ }; #endif struct semid_ds { struct ipc_perm sem_perm; /* operation permission struct */ struct sem *sem_base; /* pointer to first semaphore in set */ unsigned short sem_nsems; /* number of sems in set */ time_t sem_otime; /* last operation time */ time_t sem_ctime; /* last change time */ /* Times measured in secs since */ /* 00:00:00 UTC, Jan. 1, 1970, without leap seconds */ }; /* * semop's sops parameter structure */ struct sembuf { unsigned short sem_num; /* semaphore # */ short sem_op; /* semaphore operation */ short sem_flg; /* operation flags */ }; #define SEM_UNDO 010000 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \ defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7) || \ defined(_WANT_SEMUN_OLD) union semun_old { int val; /* value for SETVAL */ struct semid_ds_old *buf; /* buffer for IPC_STAT & IPC_SET */ unsigned short *array; /* array for GETALL & SETALL */ }; #endif /* * semctl's arg parameter structure */ union semun { int val; /* value for SETVAL */ struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */ unsigned short *array; /* array for GETALL & SETALL */ }; /* * commands for semctl */ #define GETNCNT 3 /* Return the value of semncnt {READ} */ #define GETPID 4 /* Return the value of sempid {READ} */ #define GETVAL 5 /* Return the value of semval {READ} */ #define GETALL 6 /* Return semvals into arg.array {READ} */ #define GETZCNT 7 /* Return the value of semzcnt {READ} */ #define SETVAL 8 /* Set the value of semval to arg.val {ALTER} */ #define SETALL 9 /* Set semvals from arg.array {ALTER} */ #define SEM_STAT 10 /* Like IPC_STAT but treats semid as sema-index */ #define SEM_INFO 11 /* Like IPC_INFO but treats semid as sema-index */ /* * Permissions */ #define SEM_A IPC_W /* alter permission */ #define SEM_R IPC_R /* read permission */ #ifdef _KERNEL /* * semaphore info struct */ struct seminfo { int semmni, /* # of semaphore identifiers */ semmns, /* # of semaphores in system */ semmnu, /* # of undo structures in system */ semmsl, /* max # of semaphores per id */ semopm, /* max # of operations per semop call */ semume, /* max # of undo entries per process */ semusz, /* size in bytes of undo structure */ semvmx, /* semaphore maximum value */ semaem; /* adjust on exit max value */ }; extern struct seminfo seminfo; /* * Kernel wrapper for the user-level structure */ struct semid_kernel { struct semid_ds u; struct label *label; /* MAC framework label */ struct ucred *cred; /* creator's credentials */ }; /* internal "mode" bits */ #define SEM_ALLOC 01000 /* semaphore is allocated */ #define SEM_DEST 02000 /* semaphore will be destroyed on last detach */ /* * Process sem_undo vectors at proc exit. */ void semexit(struct proc *p); -#else /* ! _KERNEL */ +#endif /* _KERNEL */ +#if !defined(_KERNEL) || defined(_WANT_SEM_PROTOTYPES) __BEGIN_DECLS #if __BSD_VISIBLE int semsys(int, ...); #endif int semctl(int, int, int, ...); int semget(key_t, int, int); int semop(int, struct sembuf *, size_t); __END_DECLS -#endif /* !_KERNEL */ +#endif /* !_KERNEL || _WANT_SEM_PROTOTYPES */ #endif /* !_SYS_SEM_H_ */ Index: head/sys/sys/shm.h =================================================================== --- head/sys/sys/shm.h (revision 286087) +++ head/sys/sys/shm.h (revision 286088) @@ -1,168 +1,169 @@ /* $FreeBSD$ */ /* $NetBSD: shm.h,v 1.15 1994/06/29 06:45:17 cgd Exp $ */ /*- * Copyright (c) 1994 Adam Glass * 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 Adam Glass. * 4. 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. */ /* * As defined+described in "X/Open System Interfaces and Headers" * Issue 4, p. XXX */ #ifndef _SYS_SHM_H_ #define _SYS_SHM_H_ #include #include #include #define SHM_RDONLY 010000 /* Attach read-only (else read-write) */ #define SHM_RND 020000 /* Round attach address to SHMLBA */ #define SHMLBA PAGE_SIZE /* Segment low boundary address multiple */ /* "official" access mode definitions; somewhat braindead since you have to specify (SHM_* >> 3) for group and (SHM_* >> 6) for world permissions */ #define SHM_R (IPC_R) #define SHM_W (IPC_W) /* predefine tbd *LOCK shmctl commands */ #define SHM_LOCK 11 #define SHM_UNLOCK 12 /* ipcs shmctl commands for Linux compatability */ #define SHM_STAT 13 #define SHM_INFO 14 #ifndef _PID_T_DECLARED typedef __pid_t pid_t; #define _PID_T_DECLARED #endif #ifndef _TIME_T_DECLARED typedef __time_t time_t; #define _TIME_T_DECLARED #endif #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \ defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7) struct shmid_ds_old { struct ipc_perm_old shm_perm; /* operation permission structure */ int shm_segsz; /* size of segment in bytes */ pid_t shm_lpid; /* process ID of last shared memory op */ pid_t shm_cpid; /* process ID of creator */ short shm_nattch; /* number of current attaches */ time_t shm_atime; /* time of last shmat() */ time_t shm_dtime; /* time of last shmdt() */ time_t shm_ctime; /* time of last change by shmctl() */ void *shm_internal; /* sysv stupidity */ }; #endif struct shmid_ds { struct ipc_perm shm_perm; /* operation permission structure */ size_t shm_segsz; /* size of segment in bytes */ pid_t shm_lpid; /* process ID of last shared memory op */ pid_t shm_cpid; /* process ID of creator */ int shm_nattch; /* number of current attaches */ time_t shm_atime; /* time of last shmat() */ time_t shm_dtime; /* time of last shmdt() */ time_t shm_ctime; /* time of last change by shmctl() */ }; #ifdef _KERNEL #include /* * System 5 style catch-all structure for shared memory constants that * might be of interest to user programs. Do we really want/need this? */ struct shminfo { u_long shmmax; /* max shared memory segment size (bytes) */ u_long shmmin; /* max shared memory segment size (bytes) */ u_long shmmni; /* max number of shared memory identifiers */ u_long shmseg; /* max shared memory segments per process */ u_long shmall; /* max amount of shared memory (pages) */ }; /* * Add a kernel wrapper to the shmid_ds struct so that private info (like the * MAC label) can be added to it, without changing the user interface. */ struct shmid_kernel { struct shmid_ds u; vm_object_t object; struct label *label; /* MAC label */ struct ucred *cred; /* creator's credendials */ }; extern struct shminfo shminfo; struct shm_info { int used_ids; unsigned long shm_tot; unsigned long shm_rss; unsigned long shm_swp; unsigned long swap_attempts; unsigned long swap_successes; }; struct thread; struct proc; struct vmspace; void shmexit(struct vmspace *); void shmfork(struct proc *, struct proc *); -#else /* !_KERNEL */ +#endif /* _KERNEL */ +#if !defined(_KERNEL) || defined(_WANT_SHM_PROTOTYPES) #include #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif __BEGIN_DECLS #ifdef __BSD_VISIBLE int shmsys(int, ...); #endif void *shmat(int, const void *, int); int shmget(key_t, size_t, int); int shmctl(int, int, struct shmid_ds *); int shmdt(const void *); __END_DECLS -#endif /* !_KERNEL */ +#endif /* _KERNEL || _WANT_SHM_PROTOTYPES */ #endif /* !_SYS_SHM_H_ */ Index: head/usr.bin/ipcrm/ipcrm.c =================================================================== --- head/usr.bin/ipcrm/ipcrm.c (revision 286087) +++ head/usr.bin/ipcrm/ipcrm.c (revision 286088) @@ -1,297 +1,300 @@ /* * Copyright (c) 1994 Adam Glass * 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 Adam Glass. * 4. 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 Adam Glass ``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 Adam Glass 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 __FBSDID("$FreeBSD$"); #include +#define _WANT_MSG_PROTOTYPES +#define _WANT_SEM_PROTOTYPES +#define _WANT_SHM_PROTOTYPES #define _KERNEL #include #include #include #undef _KERNEL #include #include #include #include #include #include #include #include "ipc.h" static int signaled; static int errflg; static int rmverbose = 0; static void usage(void) { fprintf(stderr, "usage: ipcrm [-W] [-v[v]]\n" " [-q msqid] [-m shmid] [-s semid]\n" " [-Q msgkey] [-M shmkey] [-S semkey] ...\n"); exit(1); } static int msgrm(key_t key, int id) { if (key == -1 || id == -1) { struct msqid_kernel *kxmsqids; size_t kxmsqids_len; int num; kget(X_MSGINFO, &msginfo, sizeof(msginfo)); kxmsqids_len = sizeof(struct msqid_kernel) * msginfo.msgmni; kxmsqids = malloc(kxmsqids_len); kget(X_MSQIDS, kxmsqids, kxmsqids_len); num = msginfo.msgmni; while (num-- && !signaled) if (kxmsqids[num].u.msg_qbytes != 0) { id = IXSEQ_TO_IPCID(num, kxmsqids[num].u.msg_perm); if (msgctl(id, IPC_RMID, NULL) < 0) { if (rmverbose > 1) warn("msqid(%d): ", id); errflg++; } else if (rmverbose) printf( "Removed %s %d\n", IPC_TO_STRING('Q'), id); } return signaled ? -1 : 0; /* errors maybe handled above */ } if (key) { id = msgget(key, 0); if (id == -1) return -1; } return msgctl(id, IPC_RMID, NULL); } static int shmrm(key_t key, int id) { if (key == -1 || id == -1) { struct shmid_kernel *kxshmids; size_t kxshmids_len; int num; kget(X_SHMINFO, &shminfo, sizeof(shminfo)); kxshmids_len = sizeof(struct shmid_kernel) * shminfo.shmmni; kxshmids = malloc(kxshmids_len); kget(X_SHMSEGS, kxshmids, kxshmids_len); num = shminfo.shmmni; while (num-- && !signaled) if (kxshmids[num].u.shm_perm.mode & 0x0800) { id = IXSEQ_TO_IPCID(num, kxshmids[num].u.shm_perm); if (shmctl(id, IPC_RMID, NULL) < 0) { if (rmverbose > 1) warn("shmid(%d): ", id); errflg++; } else if (rmverbose) printf( "Removed %s %d\n", IPC_TO_STRING('M'), id); } return signaled ? -1 : 0; /* errors maybe handled above */ } if (key) { id = shmget(key, 0, 0); if (id == -1) return -1; } return shmctl(id, IPC_RMID, NULL); } static int semrm(key_t key, int id) { union semun arg; if (key == -1 || id == -1) { struct semid_kernel *kxsema; size_t kxsema_len; int num; kget(X_SEMINFO, &seminfo, sizeof(seminfo)); kxsema_len = sizeof(struct semid_kernel) * seminfo.semmni; kxsema = malloc(kxsema_len); kget(X_SEMA, kxsema, kxsema_len); num = seminfo.semmni; while (num-- && !signaled) if ((kxsema[num].u.sem_perm.mode & SEM_ALLOC) != 0) { id = IXSEQ_TO_IPCID(num, kxsema[num].u.sem_perm); if (semctl(id, IPC_RMID, NULL) < 0) { if (rmverbose > 1) warn("semid(%d): ", id); errflg++; } else if (rmverbose) printf( "Removed %s %d\n", IPC_TO_STRING('S'), id); } return signaled ? -1 : 0; /* errors maybe handled above */ } if (key) { id = semget(key, 0, 0); if (id == -1) return -1; } return semctl(id, 0, IPC_RMID, arg); } static void not_configured(int signo __unused) { signaled++; } int main(int argc, char *argv[]) { int c, result, target_id; key_t target_key; while ((c = getopt(argc, argv, "q:m:s:Q:M:S:vWy")) != -1) { signaled = 0; switch (c) { case 'v': rmverbose++; break; case 'y': use_sysctl = 0; break; } } optind = 1; errflg = 0; signal(SIGSYS, not_configured); while ((c = getopt(argc, argv, "q:m:s:Q:M:S:vWy")) != -1) { signaled = 0; switch (c) { case 'q': case 'm': case 's': target_id = atoi(optarg); if (c == 'q') result = msgrm(0, target_id); else if (c == 'm') result = shmrm(0, target_id); else result = semrm(0, target_id); if (result < 0) { errflg++; if (!signaled) warn("%sid(%d): ", IPC_TO_STR(toupper(c)), target_id); else warnx( "%ss are not configured " "in the running kernel", IPC_TO_STRING(toupper(c))); } break; case 'Q': case 'M': case 'S': target_key = atol(optarg); if (target_key == IPC_PRIVATE) { warnx("can't remove private %ss", IPC_TO_STRING(c)); continue; } if (c == 'Q') result = msgrm(target_key, 0); else if (c == 'M') result = shmrm(target_key, 0); else result = semrm(target_key, 0); if (result < 0) { errflg++; if (!signaled) warn("%ss(%ld): ", IPC_TO_STR(c), target_key); else warnx("%ss are not configured " "in the running kernel", IPC_TO_STRING(c)); } break; case 'v': case 'y': /* Handled in other getopt() loop */ break; case 'W': msgrm(-1, 0); shmrm(-1, 0); semrm(-1, 0); break; case ':': fprintf(stderr, "option -%c requires an argument\n", optopt); usage(); case '?': fprintf(stderr, "unrecognized option: -%c\n", optopt); usage(); } } if (optind != argc) { fprintf(stderr, "unknown argument: %s\n", argv[optind]); usage(); } exit(errflg); }