typedef struct {
int interactive;
+ int fcntl_lock;
} conf_t;
conf_t parse_command_line(int argc, char *argv[]) {
conf_t conf;
conf.interactive = 0;
+ conf.fcntl_lock = 1;
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-i") == 0 && isatty(2))
conf.interactive = 1;
+ if (strcmp(argv[i], "--no-fnctl-lock") == 0)
+ conf.fcntl_lock = 0;
}
return conf;
die("Error writing to output file");
}
-static void take_lock(FILE *f) {
+static void take_lock(conf_t *conf, FILE *f) {
+ if (!conf->fcntl_lock)
+ return;
struct flock lock;
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
const char *now = encode_time(time(NULL));
FILE *f = fopen(FILENAME, "a");
- take_lock(f);
+ take_lock(conf, f);
write_line(now, f, line);
if (fclose(f) != 0)