/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdio_ext.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <dirent.h>
#include <errno.h>
#include <stropts.h>
#include <poll.h>
#include <procfs.h>
#include <sys/resource.h>
static int count_my_files();
static char *command;
/* slop to account for extra file descriptors opened by libraries we call */
int
{
unsigned long remain = 0;
char *arg;
unsigned i;
int verbose = 0;
command++;
else
argc--;
argv++;
verbose = 1;
argc--;
argv++;
}
if (argc <= 0) {
" -v: verbose; report terminations to standard out\n");
return (2);
}
/* make sure we have enough file descriptors */
"%s: insufficient file descriptors\n",
command);
return (2);
}
}
}
perror("malloc");
return (2);
}
for (i = 0; i < argc; i++) {
else {
}
remain++;
/*
* We set POLLPRI to detect system processes.
* We will get POLLNVAL below for a POLLPRI
* requested event on a system process.
*/
} else {
}
}
while (remain != 0) {
perror("poll");
return (2);
}
(void) sleep(2);
}
for (i = 0; i < argc; i++) {
/*
* We don't care if a non-system process
* stopped. Don't check for that again.
*/
continue;
}
if (verbose) {
== sizeof (psinfo)) {
(void) printf(
"%s: terminated, wait status 0x%.4x\n",
} else {
(void) printf(
"%s: terminated\n", arg);
}
}
(void) printf("%s: system process\n",
arg);
(void) printf("%s: unknown error\n",
arg);
}
remain--;
}
}
return (0);
}
/* ARGSUSED1 */
static int
{
(*(int *)nofilesp)++;
return (0);
}
static int
{
int nofiles = 0;
return (nofiles);
}