changeset 3438:f184ffc66b84

6479563 cpustat fails on system with 256 cpus
author as198278
date Wed, 17 Jan 2007 22:41:40 -0800
parents 464e8cf4935b
children 0302bfe973fe
files usr/src/cmd/cpc/common/cpustat.c
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/cpc/common/cpustat.c	Wed Jan 17 21:24:57 2007 -0800
+++ b/usr/src/cmd/cpc/common/cpustat.c	Wed Jan 17 22:41:40 2007 -0800
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * 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
  * or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -47,6 +46,7 @@
 #include <kstat.h>
 #include <synch.h>
 #include <libcpc.h>
+#include <sys/resource.h>
 
 #include "cpucmds.h"
 
@@ -121,6 +121,7 @@
 	char		*errstr;
 	double		period;
 	char		*endp;
+	struct rlimit	rl;
 
 	(void) setlocale(LC_ALL, "");
 	(void) textdomain(TEXT_DOMAIN);
@@ -130,6 +131,15 @@
 	else
 		opts->pgmname++;
 
+	/* Make sure we can open enough files */
+	rl.rlim_max = rl.rlim_cur = RLIM_INFINITY;
+	if (setrlimit(RLIMIT_NOFILE, &rl) != 0) {
+		errstr = strerror(errno);
+		(void) fprintf(stderr,
+			gettext("%s: setrlimit failed - %s\n"),
+			opts->pgmname, errstr);
+	}
+
 	if ((cpc = cpc_open(CPC_VER_CURRENT)) == NULL) {
 		errstr = strerror(errno);
 		(void) fprintf(stderr, gettext("%s: cannot access performance "