Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/pkg_install/add Try increasing number of max. open ...
details: https://anonhg.NetBSD.org/src/rev/4d405655f1b3
branches: trunk
changeset: 534862:4d405655f1b3
user: hubertf <hubertf%NetBSD.org@localhost>
date: Sun Aug 04 21:47:24 2002 +0000
description:
Try increasing number of max. open files as high as possible.
Prevents annoying errors when installing biggies like KDE.
diffstat:
usr.sbin/pkg_install/add/main.c | 28 +++++++++++++++++++++++-----
1 files changed, 23 insertions(+), 5 deletions(-)
diffs (66 lines):
diff -r 37d242b2fa35 -r 4d405655f1b3 usr.sbin/pkg_install/add/main.c
--- a/usr.sbin/pkg_install/add/main.c Sun Aug 04 20:50:55 2002 +0000
+++ b/usr.sbin/pkg_install/add/main.c Sun Aug 04 21:47:24 2002 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: main.c,v 1.25 2002/07/19 19:04:33 yamt Exp $ */
+/* $NetBSD: main.c,v 1.26 2002/08/04 21:47:24 hubertf Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char *rcsid = "from FreeBSD Id: main.c,v 1.16 1997/10/08 07:45:43 charnier Exp";
#else
-__RCSID("$NetBSD: main.c,v 1.25 2002/07/19 19:04:33 yamt Exp $");
+__RCSID("$NetBSD: main.c,v 1.26 2002/08/04 21:47:24 hubertf Exp $");
#endif
#endif
@@ -32,6 +32,7 @@
#include <err.h>
#include <sys/param.h>
+#include <sys/resource.h>
#include "lib.h"
#include "add.h"
#include "verify.h"
@@ -65,6 +66,8 @@
{
int ch, error=0;
lpkg_head_t pkgs;
+ struct rlimit rlim;
+ int rc;
while ((ch = getopt(argc, argv, Options)) != -1) {
switch (ch) {
@@ -141,13 +144,28 @@
TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
}
- }
- /* If no packages, yelp */
- else if (!ch)
+ } else if (!ch)
+ /* If no packages, yelp */
warnx("missing package name(s)"), usage();
else if (ch > 1 && AddMode == MASTER)
warnx("only one package name may be specified with master mode"),
usage();
+
+ /* Increase # of max. open file descriptors as high as possible */
+ rc = getrlimit(RLIMIT_NOFILE, &rlim);
+ if (rc == -1) {
+ warn("cannot retrieve max. number of open files resource limit");
+ } else {
+ rlim.rlim_cur = rlim.rlim_max;
+ rc = setrlimit(RLIMIT_NOFILE, &rlim);
+ if (rc == -1) {
+ warn("cannot increase max. number of open files resource limit, try 'ulimit'");
+ } else {
+ if (Verbose)
+ printf("increasing RLIMIT_NOFILE to max. %ld open files\n", (long)rlim.rlim_cur);
+ }
+ }
+
error += pkg_perform(&pkgs);
if (error != 0) {
if (Verbose)
Home |
Main Index |
Thread Index |
Old Index