From: danw Date: Wed, 22 Jan 1997 22:54:43 +0000 (+0000) Subject: Fix `Unable to read from program: Interrupted system call' on exit. X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/commitdiff_plain/c666a1498e27873491c7bec7541b38710063de5a Fix `Unable to read from program: Interrupted system call' on exit. Also sync code between startdcm, startreg, and startmoira --- diff --git a/dcm/startdcm.c b/dcm/startdcm.c index e2fdac8b..0f31bcfb 100644 --- a/dcm/startdcm.c +++ b/dcm/startdcm.c @@ -32,7 +32,7 @@ static char *rcsid_mr_starter_c = "$Header$"; int rdpipe[2]; extern int errno; -void cleanup() +cleanup() { int stat, serrno = errno; char buf[BUFSIZ]; @@ -47,7 +47,7 @@ void cleanup() WEXITSTATUS(stat)); } if (WIFSIGNALED(stat)) { - sprintf(buf, "exited with signal %d%s\n", + sprintf(buf, "exited on signal %d%s\n", WTERMSIG(stat), (WCOREDUMP(stat)?"; Core dumped":0)); } @@ -69,7 +69,7 @@ main(argc, argv) struct sigaction action; int nfds; - + getrlimit(RLIMIT_NOFILE, &rl); nfds = rl.rlim_cur; @@ -77,7 +77,7 @@ main(argc, argv) action.sa_flags = 0; sigemptyset(&action.sa_mask); sigaction(SIGCHLD, &action, NULL); - + sprintf(buf, "%s/%s.log", SMS_DIR, PROG); logf = open(buf, O_CREAT|O_WRONLY|O_APPEND, 0640); if (logf<0) { @@ -131,7 +131,7 @@ main(argc, argv) done = 0; errno = 0; if (fgets(buf, BUFSIZ, prog) == NULL) { - if (errno) { + if (errno && errno!=EINTR) { strcpy(buf, "Unable to read from program: "); strcat(buf, sys_errlist[errno]); strcat(buf, "\n"); @@ -145,7 +145,3 @@ main(argc, argv) } while (!done); exit(0); } - - - - diff --git a/reg_svr/startreg.c b/reg_svr/startreg.c index 92d6fc6c..2b620fcc 100644 --- a/reg_svr/startreg.c +++ b/reg_svr/startreg.c @@ -24,20 +24,18 @@ static char *rcsid_mr_starter_c = "$Header$"; #include #include #include -#include #include #include #define PROG "reg_svr" int rdpipe[2]; +extern int errno; cleanup() { - int stat; + int stat, serrno = errno; char buf[BUFSIZ]; - extern int errno; - int serrno = errno; buf[0]='\0'; @@ -133,7 +131,7 @@ main(argc, argv) done = 0; errno = 0; if (fgets(buf, BUFSIZ, prog) == NULL) { - if (errno) { + if (errno && errno!=EINTR) { strcpy(buf, "Unable to read from program: "); strcat(buf, sys_errlist[errno]); strcat(buf, "\n"); @@ -147,7 +145,3 @@ main(argc, argv) } while (!done); exit(0); } - - - - diff --git a/server/startmoira.c b/server/startmoira.c index 71323cf9..f35fa07f 100644 --- a/server/startmoira.c +++ b/server/startmoira.c @@ -24,24 +24,21 @@ static char *rcsid_mr_starter_c = "$Header$"; #include #include #include -#include -#include -#include #include +#include +#include #define PROG "moirad" int rdpipe[2]; +extern int errno; char *whoami; cleanup() { - int stat; - + int stat, serrno = errno; char buf[BUFSIZ]; - extern int errno; - int serrno = errno; buf[0]='\0'; @@ -80,9 +77,9 @@ main(argc, argv) struct sigaction action; int nfds; - + whoami = argv[0]; - + getrlimit(RLIMIT_NOFILE, &rl); nfds = rl.rlim_cur; @@ -144,7 +141,7 @@ main(argc, argv) done = 0; errno = 0; if (fgets(buf, BUFSIZ, prog) == NULL) { - if (errno) { + if (errno && errno!=EINTR) { strcpy(buf, "Unable to read from program: "); strcat(buf, sys_errlist[errno]); strcat(buf, "\n"); @@ -158,7 +155,3 @@ main(argc, argv) } while (!done); exit(0); } - - - -