On 08/01/2012 03:13 PM, Chet Ramey wrote:
On 7/30/12 10:41 AM, Roman Rakus wrote:
Hmm... I don't know much about boundaries of maximum number of user
processes. But anyway - do you think that (re)changing js.c_childmax (when
`ulimit -u' is changed) is not good?
Maybe it's ok up to some fixed upper bound.  But if you're going to have
that fixed upper bound, why not just use it as the number of job exit
statuses to remember all the time?

I prepared a patch which add configure option to enable and set the number of job exit statuses to remember. I found that posix is talking about changing system configurable variables and values; quoting:
"""
This runtime facility is not meant to provide ever-changing values that applications have to check multiple times. The values are seen as changing no more frequently than once per system initialization, such as by a system administrator or operator with an automatic configuration program. This volume of POSIX.1-2008 specifies that they shall not change within the lifetime of the process.
"""
(see http://pubs.opengroup.org/onlinepubs/9699919799/functions/sysconf.html)
So I would tell that bash does not need to check every time maxchild value.
However, when the maxchild is set to unlimited, now the bash will use predefined DEFAULT_CHILD_MAX which is set to 32. The attached patch adds ability to set forced number of remembered statuses, easily during configure time, example:
 ./configure --enable-fixedjsmax=2048
It will force bash to remember 2048 statuses, independently on childmax value.
Patch should clearly apply to git master branch.
Chet, what do you think about it?

RR
>From 32701d12fc6ddf8e3289ea920423c0e55210e3a5 Mon Sep 17 00:00:00 2001
From: Roman Rakus <rra...@redhat.com>
Date: Thu, 23 Aug 2012 19:35:52 +0200
Subject: [PATCH] Option to use fixed number of remembered job exit statuses

Signed-off-by: Roman Rakus <rra...@redhat.com>
---
 config.h.in  |  3 +++
 configure.in | 13 +++++++++++++
 jobs.c       |  8 ++++++++
 3 files changed, 24 insertions(+)

diff --git a/config.h.in b/config.h.in
index 6b1fc4a..b09b939 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1125,6 +1125,9 @@
 
 /* End additions for lib/intl */
 
+/* Define if you want to use fixed number of remembered job exit statuses */
+#undef USE_FIXEDJSMAX_NUMBER
+
 #include "config-bot.h"
 
 #endif /* _CONFIG_H_ */
diff --git a/configure.in b/configure.in
index d7e0998..dd5e0c9 100644
--- a/configure.in
+++ b/configure.in
@@ -1107,6 +1107,19 @@ case "$srcdir" in
 	;;
 esac
 
+AC_MSG_CHECKING([whether to use fixed number of remembered job exit statuses])
+AC_ARG_ENABLE([fixedjsmax],
+      [AS_HELP_STRING([--enable-fixedjsmax=number],
+                     [Enable fixed number of remembered job exit statuses])],
+      [ENABLE_FIXEDJSMAX="${enableval}"], [ENABLE_FIXEDJSMAX='no'])
+AC_MSG_RESULT(${ENABLE_FIXEDJSMAX})
+if test "x${ENABLE_FIXEDJSMAX}" != xno; then
+  AS_IF([test "${ENABLE_FIXEDJSMAX}" -gt "0" 2>/dev/null],
+        AC_DEFINE_UNQUOTED(USE_FIXEDJSMAX_NUMBER, [${ENABLE_FIXEDJSMAX}]),
+        AC_MSG_ERROR([invalid value]))
+fi
+
+
 BUILD_DIR=`pwd`
 case "$BUILD_DIR" in
 *\ *)	BUILD_DIR=`echo "$BUILD_DIR" | sed 's: :\\\\ :g'` ;;
diff --git a/jobs.c b/jobs.c
index d63c5dd..7744b5e 100644
--- a/jobs.c
+++ b/jobs.c
@@ -3723,9 +3723,13 @@ initialize_job_control (force)
     get_tty_state ();
 
   if (js.c_childmax < 0)
+#if defined (USE_FIXEDJSMAX_NUMBER)
+    js.c_childmax = USE_FIXEDJSMAX_NUMBER;
+#else
     js.c_childmax = getmaxchild ();
   if (js.c_childmax < 0)
     js.c_childmax = DEFAULT_CHILD_MAX;
+#endif
 
   return job_control;
 }
@@ -4092,9 +4096,13 @@ mark_dead_jobs_as_notified (force)
 #endif
 
   if (js.c_childmax < 0)
+#if defined (USE_FIXEDJSMAX_NUMBER)
+    js.c_childmax = USE_FIXEDJSMAX_NUMBER;
+#else
     js.c_childmax = getmaxchild ();
   if (js.c_childmax < 0)
     js.c_childmax = DEFAULT_CHILD_MAX;
+#endif
 
   /* Don't do anything if the number of dead processes is less than CHILD_MAX
      and we're not forcing a cleanup. */
-- 
1.7.11.4

Reply via email to