From 5fbf37ee68e018998ada61eeab73e035b26834b6 Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Wed, 21 Mar 2012 20:47:48 +0100 Subject: [PATCH] On today's systems fork() will hardly fail, thus removed the fork retry loops. --- sbr/context_save.c | 6 +----- sbr/push.c | 6 +----- uip/mhbuildsbr.c | 6 ++---- uip/mhmail.c | 5 +---- uip/mhparse.c | 12 ++++-------- uip/mhshowsbr.c | 12 +++--------- uip/send.c | 15 ++++----------- uip/whatnow.c | 6 ++---- 8 files changed, 18 insertions(+), 50 deletions(-) diff --git a/sbr/context_save.c b/sbr/context_save.c index 44542b5..1a381db 100644 --- a/sbr/context_save.c +++ b/sbr/context_save.c @@ -68,16 +68,12 @@ context_save(void) static int m_chkids(void) { - int i; pid_t pid; if (getuid() == geteuid()) return (-1); - for (i = 0; (pid = fork()) == -1 && i < 5; i++) - sleep(5); - - switch (pid) { + switch (pid = fork()) { case -1: break; diff --git a/sbr/push.c b/sbr/push.c index 17c62ee..eb6011a 100644 --- a/sbr/push.c +++ b/sbr/push.c @@ -15,12 +15,8 @@ void push(void) { pid_t pid; - int i; - for (i = 0; (pid = fork()) == -1 && i < 5; i++) - sleep(5); - - switch (pid) { + switch (pid = fork()) { case -1: /* fork error */ advise(NULL, "unable to fork, so can't push..."); diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index 069ea85..efbb8ac 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -1017,7 +1017,7 @@ compose_content(CT ct) default: if (!ce->ce_file) { pid_t child_id; - int i, xstdout, len, buflen; + int xstdout, len, buflen; char *bp, **ap, *cp; char *vec[4], buffer[BUFSIZ]; FILE *out; @@ -1119,9 +1119,7 @@ raw: if ((out = fopen(ce->ce_file, "w")) == NULL) adios(ce->ce_file, "unable to open for writing"); - for (i = 0; (child_id = fork()) == NOTOK && i > 5; i++) - sleep(5); - switch (child_id) { + switch (child_id = fork()) { case NOTOK: adios("fork", "unable to fork"); /* NOTREACHED */ diff --git a/uip/mhmail.c b/uip/mhmail.c index f9e7fcd..2b8589f 100644 --- a/uip/mhmail.c +++ b/uip/mhmail.c @@ -173,10 +173,7 @@ main(int argc, char **argv) vec[nvec++] = "-queued"; vec[nvec] = NULL; - for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++) - sleep(5); - - if (child_id == NOTOK) { + if ((child_id = fork()) == NOTOK) { /* report failure and then send it */ adios(NULL, "unable to fork"); } else if (child_id) { diff --git a/uip/mhparse.c b/uip/mhparse.c index 86c16a9..b3b07e4 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -2472,7 +2472,7 @@ openFTP(CT ct, char **file) CE ce; static char *username = NULL; static char *password = NULL; - int child_id, i, vecp; + int child_id, vecp; char *vec[9]; e = ct->c_ctexbody; @@ -2598,9 +2598,7 @@ openFTP(CT ct, char **file) fflush(stdout); - for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++) - sleep(5); - switch (child_id) { + switch (child_id = fork()) { case NOTOK: adios("fork", "unable to"); /* NOTREACHED */ @@ -2674,7 +2672,7 @@ InitMail(CT ct) static int openMail(CT ct, char **file) { - int child_id, fd, i, vecp; + int child_id, fd, vecp; int len, buflen; char *bp, buffer[BUFSIZ], *vec[7]; struct exbody *e = ct->c_ctexbody; @@ -2734,9 +2732,7 @@ openMail(CT ct, char **file) vec[vecp++] = e->eb_body; vec[vecp] = NULL; - for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++) - sleep(5); - switch (child_id) { + switch (child_id = fork()) { case NOTOK: advise("fork", "unable to"); return NOTOK; diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index 15991c1..fe9a626 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -186,7 +186,7 @@ static void DisplayMsgHeader(CT ct, char *form) { pid_t child_id; - int i, vecp; + int vecp; char *vec[8]; vecp = 0; @@ -205,10 +205,7 @@ DisplayMsgHeader(CT ct, char *form) fflush(stdout); - for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++) - sleep(5); - - switch (child_id) { + switch (child_id = fork()) { case NOTOK: adios("fork", "unable to"); /* NOTREACHED */ @@ -519,7 +516,6 @@ show_content_aux2(CT ct, int serial, int alternate, char *cracked, char *buffer, int fd, int xlist, int xstdin, int xtty) { pid_t child_id; - int i; char *vec[4], exec[BUFSIZ + sizeof "exec "]; if (debugsw || cracked) { @@ -559,9 +555,7 @@ show_content_aux2(CT ct, int serial, int alternate, char *cracked, fflush(stdout); - for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++) - sleep(5); - switch (child_id) { + switch (child_id = fork()) { case NOTOK: advise("fork", "unable to"); (*ct->c_ceclosefnx) (ct); diff --git a/uip/send.c b/uip/send.c index 6fcccad..2ef1fe7 100644 --- a/uip/send.c +++ b/uip/send.c @@ -620,7 +620,7 @@ static int sendaux(char **vec, int vecp, char *drft, struct stat *st) { pid_t child_id; - int i, status, fd; + int status, fd; char backup[BUFSIZ]; /* @@ -635,10 +635,7 @@ sendaux(char **vec, int vecp, char *drft, struct stat *st) } vec[vecp] = NULL; - for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++) { - sleep(5); - } - switch (child_id) { + switch (child_id = fork()) { case -1: /* oops -- fork error */ adios("fork", "unable to"); @@ -703,14 +700,10 @@ static void alert(char *file, int out) { pid_t child_id; - int i, in; + int in; char buf[BUFSIZ]; - for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++) { - sleep(5); - } - - switch (child_id) { + switch (child_id = fork()) { case NOTOK: /* oops -- fork error */ advise("fork", "unable to"); diff --git a/uip/whatnow.c b/uip/whatnow.c index 761fea1..b809ebe 100644 --- a/uip/whatnow.c +++ b/uip/whatnow.c @@ -770,15 +770,13 @@ static int sendfile(char **arg, char *file, int pushsw) { pid_t child_id; - int i, vecp; + int vecp; char *vec[MAXARGS]; context_save(); /* save the context file */ fflush(stdout); - for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++) - sleep(5); - switch (child_id) { + switch (child_id = fork()) { case NOTOK: advise(NULL, "unable to fork, so sending directly..."); /* fall */ -- 1.7.10.4