Hi all,
I'm using bash 3.1 on interix. There fork() may fail with EAGAIN if
e.g. several builds (configures) are running in parallel.
Unfortunately, fork() isn't retried and configure stops.
So I suggest adding this patch to bash which retries fork() when it
fails with EAGAIN. Idea is from pdksh. At least 3.2 doesn't have
such a patch, I didn't look though all the patches after 3.2, however.
Martin
--- bash/jobs.c.orig Wed Jun 20 00:02:39 2007
+++ bash/jobs.c Sun Sep 16 23:29:41 2007
@@ -1611,6 +1611,7 @@
{
sigset_t set, oset;
pid_t pid;
+ unsigned int forksleep;
sigemptyset (&set);
sigaddset (&set, SIGCHLD);
@@ -1631,9 +1632,16 @@
#endif /* BUFFERED_INPUT */
/* Create the child, handle severe errors. */
- if ((pid = fork ()) < 0)
+ forksleep = 1;
+ while ((pid = fork ()) < 0 && errno == EAGAIN && forksleep < 32)
{
- sys_error ("fork");
+ if (sleep (forksleep)) break; /* break on signals, e.g. ^C */
+ forksleep <<= 1;
+ }
+
+ if (pid < 0)
+ {
+ sys_error ("fork");
/* Kill all of the processes in the current pipeline. */
terminate_current_pipeline ();