X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/d8feebc2af6d893304b40de06ea2e9820044f2f9..72b2a7a51313d81ea64f26dc0dc872823a5cd4f3:/usr/src/usr.bin/tip/log.c diff --git a/usr/src/usr.bin/tip/log.c b/usr/src/usr.bin/tip/log.c index dfe586ec7a..6a3e3da44e 100644 --- a/usr/src/usr.bin/tip/log.c +++ b/usr/src/usr.bin/tip/log.c @@ -1,8 +1,16 @@ -/* 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 @@ -17,8 +25,8 @@ logent(group, num, acu, message) 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) @@ -38,12 +46,15 @@ logent(group, num, acu, message) #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 +}