aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/sendmail/mailstats/mailstats.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/sendmail/mailstats/mailstats.c')
-rw-r--r--usr.sbin/sendmail/mailstats/mailstats.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/usr.sbin/sendmail/mailstats/mailstats.c b/usr.sbin/sendmail/mailstats/mailstats.c
index 97ec33be7e92..cf112185cbca 100644
--- a/usr.sbin/sendmail/mailstats/mailstats.c
+++ b/usr.sbin/sendmail/mailstats/mailstats.c
@@ -40,9 +40,10 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)mailstats.c 8.4 (Berkeley) 8/14/94";
+static char sccsid[] = "@(#)mailstats.c 8.8 (Berkeley) 9/25/96";
#endif /* not lint */
+#define NOT_SENDMAIL
#include <sendmail.h>
#include <mailstats.h>
#include <pathnames.h>
@@ -91,7 +92,8 @@ main(argc, argv)
case '?':
default:
usage:
- fputs("usage: mailstats [-C cffile] [-f stfile]\n", stderr);
+ fputs("usage: mailstats [-o] [-C cffile] [-f stfile]\n",
+ stderr);
exit(EX_USAGE);
}
}
@@ -189,13 +191,24 @@ main(argc, argv)
exit (EX_OSFILE);
}
- if ((fd = open(sfile, O_RDONLY)) < 0) {
+ if ((fd = open(sfile, O_RDONLY)) < 0 ||
+ (i = read(fd, &stat, sizeof stat)) < 0)
+ {
fputs("mailstats: ", stderr);
perror(sfile);
exit(EX_NOINPUT);
}
- if (read(fd, &stat, sizeof(stat)) != sizeof(stat) ||
- stat.stat_size != sizeof(stat))
+ if (i == 0)
+ {
+ sleep(1);
+ i = read(fd, &stat, sizeof stat);
+ if (i == 0)
+ {
+ bzero((ARBPTR_T) &stat, sizeof stat);
+ (void) time(&stat.stat_itime);
+ }
+ }
+ else if (i != sizeof stat || stat.stat_size != sizeof(stat))
{
fputs("mailstats: file size changed.\n", stderr);
exit(EX_OSERR);