chris@mimsy.UUCP (Chris Torek) (08/26/87)
Index: etc/cron.c 4.3BSD Fix Description: Cron has quite a bit of lint. Repeat-By: cd /usr/src/etc; lint -h cron.c Fix: Below. I elected not to do anything about the fflush() calls, because I have another idea for those involving further changes to syslog, and I left the calls to setgid and setuid alone because I expect pw_gid and pw_uid to change in the future. RCS file: RCS/cron.c,v retrieving revision 1.2 retrieving revision 1.3 diff -c2 -r1.2 -r1.3 *** /tmp/,RCSt1005717 Tue Aug 25 22:31:15 1987 --- /tmp/,RCSt2005717 Tue Aug 25 22:31:16 1987 *************** *** 12,15 **** --- 12,16 ---- #include <sys/ioctl.h> #include <sys/file.h> + #include <sys/resource.h> #include <pwd.h> #include <fcntl.h> *************** *** 35,39 **** char crontab[] = CRONTAB; char loc_crontab[] = CRONTABLOC; ! time_t itime; struct tm *loct; struct tm *localtime(); --- 36,40 ---- char crontab[] = CRONTAB; char loc_crontab[] = CRONTABLOC; ! time_t itime, time(); struct tm *loct; struct tm *localtime(); *************** *** 80,94 **** if (debug == NULL) exit(1); ! fcntl(fileno(debug), F_SETFL, FAPPEND); } ! chdir("/"); ! freopen("/", "r", stdout); ! freopen("/", "r", stderr); untty(); ! signal(SIGHUP, SIG_IGN); ! signal(SIGINT, SIG_IGN); ! signal(SIGQUIT, SIG_IGN); ! signal(SIGCHLD, reapchild); ! time(&itime); itime -= localtime(&itime)->tm_sec; --- 81,95 ---- if (debug == NULL) exit(1); ! (void) fcntl(fileno(debug), F_SETFL, FAPPEND); } ! (void) chdir("/"); ! (void) freopen("/", "r", stdout); ! (void) freopen("/", "r", stderr); untty(); ! (void) signal(SIGHUP, SIG_IGN); ! (void) signal(SIGINT, SIG_IGN); ! (void) signal(SIGQUIT, SIG_IGN); ! (void) signal(SIGCHLD, reapchild); ! (void) time(&itime); itime -= localtime(&itime)->tm_sec; *************** *** 182,186 **** time_t t; ! time(&t); i = itime - t; if(i < -60 * 60 || i > 60 * 60) { --- 183,187 ---- time_t t; ! (void) time(&t); i = itime - t; if(i < -60 * 60 || i > 60 * 60) { *************** *** 190,194 **** } if(i > 0) ! sleep(i); } --- 191,195 ---- } if(i > 0) ! sleep((unsigned)i); } *************** *** 196,200 **** char *s; { - int st; register struct passwd *pwd; char user[BUFSIZ]; --- 197,200 ---- *************** *** 228,232 **** } (void) setgid(pwd->pw_gid); ! initgroups(pwd->pw_name, pwd->pw_gid); (void) setuid(pwd->pw_uid); (void) freopen("/", "r", stdin); --- 228,232 ---- } (void) setgid(pwd->pw_gid); ! (void) initgroups(pwd->pw_name, pwd->pw_gid); (void) setuid(pwd->pw_uid); (void) freopen("/", "r", stdin); *************** *** 339,343 **** while(c != '\n') { if(c == EOF) { ! fclose(stdin); listend = cp; return; --- 339,343 ---- while(c != '\n') { if(c == EOF) { ! (void) fclose(stdin); listend = cp; return; *************** *** 357,361 **** c = getchar(); } ! ungetc(c, stdin); if (n>=100) return(-1); --- 357,361 ---- c = getchar(); } ! (void) ungetc(c, stdin); if (n>=100) return(-1); *************** *** 368,372 **** int pid; ! while ((pid = wait3(&status, WNOHANG, 0)) > 0) dprintf(debug, "%d: child exits with signal %d status %d\n", pid, status.w_termsig, status.w_retcode), --- 368,372 ---- int pid; ! while ((pid = wait3(&status, WNOHANG, (struct rusage *)0)) > 0) dprintf(debug, "%d: child exits with signal %d status %d\n", pid, status.w_termsig, status.w_retcode), *************** *** 380,384 **** i = open("/dev/tty", O_RDWR); if (i >= 0) { ! ioctl(i, TIOCNOTTY, (char *)0); (void) close(i); } --- 380,384 ---- i = open("/dev/tty", O_RDWR); if (i >= 0) { ! (void) ioctl(i, TIOCNOTTY, (char *)0); (void) close(i); } -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: seismo!mimsy!chris