• implement fcntl(2)-based advisory locking as an alternative iff flock(2)
is not found, from a suggestion by RT (LP: #912691) • try harder (in a loop) to acquire a file lock if the locking mechanism documents EINTR is a possibility (fcntl always, flock on Linux not .Ox) • use -std=c99 not -std=gnu99 if it must be at all
This commit is contained in:
6
main.c
6
main.c
@ -34,7 +34,7 @@
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.211 2012/03/25 14:28:14 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.212 2012/03/27 22:36:52 tg Exp $");
|
||||
|
||||
extern char **environ;
|
||||
|
||||
@ -1721,7 +1721,7 @@ DF(const char *fmt, ...)
|
||||
va_list args;
|
||||
struct timeval tv;
|
||||
|
||||
(void)flock(shl_dbg_fd, LOCK_EX);
|
||||
mksh_lockfd(shl_dbg_fd);
|
||||
gettimeofday(&tv, NULL);
|
||||
shf_fprintf(shl_dbg, "[%d.%06d:%d] ", (int)tv.tv_sec, (int)tv.tv_usec,
|
||||
(int)getpid());
|
||||
@ -1730,6 +1730,6 @@ DF(const char *fmt, ...)
|
||||
va_end(args);
|
||||
shf_putc('\n', shl_dbg);
|
||||
shf_flush(shl_dbg);
|
||||
(void)flock(shl_dbg_fd, LOCK_UN);
|
||||
mksh_unlkfd(shl_dbg_fd);
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user