+
+ /* Initialize with 0-bytes, just to be sure… */
+ memset(logbuffer, '\0', logbuffer_size);
+
+ header = (i3_shmlog_header *)logbuffer;
+
+#if !defined(__OpenBSD__)
+ pthread_condattr_t cond_attr;
+ pthread_condattr_init(&cond_attr);
+ if (pthread_condattr_setpshared(&cond_attr, PTHREAD_PROCESS_SHARED) != 0)
+ fprintf(stderr, "pthread_condattr_setpshared() failed, i3-dump-log -f will not work!\n");
+ pthread_cond_init(&(header->condvar), &cond_attr);
+#endif
+
+ logwalk = logbuffer + sizeof(i3_shmlog_header);
+ loglastwrap = logbuffer + logbuffer_size;
+ store_log_markers();
+}
+
+/*
+ * Closes the logbuffer.
+ *
+ */
+void close_logbuffer(void) {
+ close(logbuffer_shm);
+ shm_unlink(shmlogname);
+ free(shmlogname);
+ logbuffer = NULL;
+ shmlogname = "";