summaryrefslogtreecommitdiff
path: root/jobs.c
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2011-12-07 09:13:02 -0500
committerChet Ramey <chet.ramey@case.edu>2011-12-07 09:13:02 -0500
commit79e6c7dcc896a2cff9ddf64ea5e193ddea6aec88 (patch)
treec7b49a7d04061c9cb947b882ce94e7d5c85d8976 /jobs.c
parent53ac45a3eb74f5acbc24458a51724c9db80acc55 (diff)
downloadbash-79e6c7dcc896a2cff9ddf64ea5e193ddea6aec88.tar.gz
commit bash-20070920 snapshot
Diffstat (limited to 'jobs.c')
-rw-r--r--jobs.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/jobs.c b/jobs.c
index d94cc5fa..82a6b488 100644
--- a/jobs.c
+++ b/jobs.c
@@ -1674,6 +1674,7 @@ make_child (command, async_p)
char *command;
int async_p;
{
+ int forksleep;
sigset_t set, oset;
pid_t pid;
@@ -1695,8 +1696,16 @@ make_child (command, async_p)
sync_buffered_stream (default_buffered_input);
#endif /* BUFFERED_INPUT */
- /* Create the child, handle severe errors. */
- if ((pid = fork ()) < 0)
+ /* Create the child, handle severe errors. Retry on EAGAIN. */
+ while ((pid = fork ()) < 0 && errno == EAGAIN && forksleep < FORKSLEEP_MAX)
+ {
+ sys_error ("fork: retry");
+ if (sleep (forksleep) != 0)
+ break;
+ forksleep <<= 1;
+ }
+
+ if (pid < 0)
{
sys_error ("fork");