static char *sccsid
= "@(#)cron.c 4.11 (Berkeley) %G%";
#define CRONTAB "/usr/lib/crontab"
#define CRONTABLOC "/usr/lib/crontab.local"
char crontab
[] = CRONTAB
;
char loc_crontab
[] = CRONTABLOC
;
freopen("/", "r", stdout
);
freopen("/", "r", stderr
);
signal(SIGQUIT
, SIG_IGN
);
signal(SIGCHLD
, reapchild
);
itime
-= localtime(&itime
)->tm_sec
;
for (;; itime
+=60, slp()) {
struct stat cstat
, lcstat
;
if (stat(crontab
, &cstat
) < 0)
if (cstat
.st_mtime
!= filetime
) {
filetime
= cstat
.st_mtime
;
if (stat(loc_crontab
, &lcstat
) < 0)
if (lcstat
.st_mtime
!= lfiletime
) {
lfiletime
= lcstat
.st_mtime
;
loct
= localtime(&itime
);
loct
->tm_mon
++; /* 1-12 for month */
loct
->tm_wday
= 7; /* sunday is 7, not 0 */
for(cp
= list
; *cp
!= EOS
;) {
cp
= cmp(cp
, loct
->tm_min
);
cp
= cmp(cp
, loct
->tm_hour
);
cp
= cmp(cp
, loct
->tm_mday
);
cp
= cmp(cp
, loct
->tm_mon
);
cp
= cmp(cp
, loct
->tm_wday
);
if(i
< -60 * 60 || i
> 60 * 60) {
i
= 60 - localtime(&itime
)->tm_sec
;
register struct passwd
*pwd
;
while(*s
!= ' ' && *s
!= '\t')
if ((pwd
= getpwnam(user
)) == NULL
) {
(void) setgid(pwd
->pw_gid
);
initgroups(pwd
->pw_name
, pwd
->pw_gid
);
(void) setuid(pwd
->pw_uid
);
freopen("/", "r", stdin
);
execl("/bin/sh", "sh", "-c", ++s
, 0);
* Don't free in case was longer than LISTS. Trades off
* the rare case of crontab shrinking vs. the common case of
* extra realloc's needed in append() for a large crontab.
if (freopen(fn
, "r", stdin
) == NULL
)
if(cp
> list
+listsize
-MAXLIN
) {
list
= realloc(list
, listsize
);
while(c
== ' ' || c
== '\t')
if(c
== EOF
|| c
== '\n')
if(c
!= '\t' && c
!= ' ')
if ((n
= number(getchar())) < 0)
if(c
!= '\t' && c
!= ' ')
if ((n
= number(getchar())) < 0)
if(c
!= '\t' && c
!= ' ')
while(wait3(&status
, WNOHANG
, 0) > 0)
i
= open("/dev/tty", O_RDWR
);
ioctl(i
, TIOCNOTTY
, (char *)0);