BSD 4_3_Tahoe release
[unix-history] / usr / src / usr.bin / tip / log.c
index dfe586e..24391a4 100644 (file)
@@ -1,8 +1,17 @@
-/*     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.2 (Berkeley) 5/2/87";
+#endif not lint
+
 #include "tip.h"
 
 #ifdef ACULOG
 #include "tip.h"
 
 #ifdef ACULOG
-static FILE *flog = NULL;
+static FILE *flog = NULL;
 
 /*
  * Log file maintenance routines
 
 /*
  * Log file maintenance routines
@@ -17,8 +26,8 @@ logent(group, num, acu, message)
 
        if (flog == NULL)
                return;
 
        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)
                return;
        }
        if ((user = getlogin()) == NOSTR)
@@ -37,13 +46,14 @@ logent(group, num, acu, message)
                num,
 #endif
                acu, message);
                num,
 #endif
                acu, message);
-       fflush(flog);
-       unlock();
+       (void) fflush(flog);
+       (void) flock(fileno(flog), LOCK_UN);
 }
 
 loginit()
 {
 }
 
 loginit()
 {
-       if ((flog = fopen(value(LOG), "a")) == NULL)
-               fprintf(stderr, "can't open log file\r\n");
+       flog = fopen(value(LOG), "a");
+       if (flog == NULL)
+               fprintf(stderr, "can't open log file %s.\r\n", value(LOG));
 }
 #endif
 }
 #endif