-/* log.c 4.2 81/11/20 */
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)log.c 5.1 (Berkeley) %G%";
+#endif not lint
+
#include "tip.h"
-#ifdef ACULOG
-static FILE *flog = NULL;
+static FILE *flog = NULL;
/*
* Log file maintenance routines
if (flog == NULL)
return;
- if (!lock(value(LOCK))) {
- fprintf(stderr, "can't lock up accounting file\r\n");
+ if (flock(fileno(flog), LOCK_EX) < 0) {
+ perror("tip: flock");
return;
}
if ((user = getlogin()) == NOSTR)
#endif
acu, message);
fflush(flog);
- unlock();
+ (void) flock(fileno(flog), LOCK_UN);
}
loginit()
{
- if ((flog = fopen(value(LOG), "a")) == NULL)
+
+#ifdef ACULOG
+ flog = fopen(value(LOG), "a");
+ if (flog == NULL)
fprintf(stderr, "can't open log file\r\n");
-}
#endif
+}