Do not use ELOG while logwalk is not initialized
This commit is contained in:
parent
eb601a2615
commit
f530e5452d
12
src/log.c
12
src/log.c
|
@ -81,11 +81,11 @@ static void store_log_markers(void) {
|
||||||
void init_logging(void) {
|
void init_logging(void) {
|
||||||
if (!errorfilename) {
|
if (!errorfilename) {
|
||||||
if (!(errorfilename = get_process_filename("errorlog")))
|
if (!(errorfilename = get_process_filename("errorlog")))
|
||||||
ELOG("Could not initialize errorlog\n");
|
fprintf(stderr, "Could not initialize errorlog\n");
|
||||||
else {
|
else {
|
||||||
errorfile = fopen(errorfilename, "w");
|
errorfile = fopen(errorfilename, "w");
|
||||||
if (fcntl(fileno(errorfile), F_SETFD, FD_CLOEXEC)) {
|
if (fcntl(fileno(errorfile), F_SETFD, FD_CLOEXEC)) {
|
||||||
ELOG("Could not set close-on-exec flag\n");
|
fprintf(stderr, "Could not set close-on-exec flag\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,14 +110,14 @@ void init_logging(void) {
|
||||||
sasprintf(&shmlogname, "/i3-log-%d", getpid());
|
sasprintf(&shmlogname, "/i3-log-%d", getpid());
|
||||||
logbuffer_shm = shm_open(shmlogname, O_RDWR | O_CREAT, S_IREAD | S_IWRITE);
|
logbuffer_shm = shm_open(shmlogname, O_RDWR | O_CREAT, S_IREAD | S_IWRITE);
|
||||||
if (logbuffer_shm == -1) {
|
if (logbuffer_shm == -1) {
|
||||||
ELOG("Could not shm_open SHM segment for the i3 log: %s\n", strerror(errno));
|
fprintf(stderr, "Could not shm_open SHM segment for the i3 log: %s\n", strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ftruncate(logbuffer_shm, logbuffer_size) == -1) {
|
if (ftruncate(logbuffer_shm, logbuffer_size) == -1) {
|
||||||
close(logbuffer_shm);
|
close(logbuffer_shm);
|
||||||
shm_unlink("/i3-log-");
|
shm_unlink("/i3-log-");
|
||||||
ELOG("Could not ftruncate SHM segment for the i3 log: %s\n", strerror(errno));
|
fprintf(stderr, "Could not ftruncate SHM segment for the i3 log: %s\n", strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ void init_logging(void) {
|
||||||
if (logbuffer == MAP_FAILED) {
|
if (logbuffer == MAP_FAILED) {
|
||||||
close(logbuffer_shm);
|
close(logbuffer_shm);
|
||||||
shm_unlink("/i3-log-");
|
shm_unlink("/i3-log-");
|
||||||
ELOG("Could not mmap SHM segment for the i3 log: %s\n", strerror(errno));
|
fprintf(stderr, "Could not mmap SHM segment for the i3 log: %s\n", strerror(errno));
|
||||||
logbuffer = NULL;
|
logbuffer = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ void init_logging(void) {
|
||||||
pthread_condattr_t cond_attr;
|
pthread_condattr_t cond_attr;
|
||||||
pthread_condattr_init(&cond_attr);
|
pthread_condattr_init(&cond_attr);
|
||||||
if (pthread_condattr_setpshared(&cond_attr, PTHREAD_PROCESS_SHARED) != 0)
|
if (pthread_condattr_setpshared(&cond_attr, PTHREAD_PROCESS_SHARED) != 0)
|
||||||
ELOG("pthread_condattr_setpshared() failed, i3-dump-log -f will not work!\n");
|
fprintf(stderr, "pthread_condattr_setpshared() failed, i3-dump-log -f will not work!\n");
|
||||||
pthread_cond_init(&(header->condvar), &cond_attr);
|
pthread_cond_init(&(header->condvar), &cond_attr);
|
||||||
|
|
||||||
logwalk = logbuffer + sizeof(i3_shmlog_header);
|
logwalk = logbuffer + sizeof(i3_shmlog_header);
|
||||||
|
|
Loading…
Reference in New Issue