+ }
+ /* Start SHM logging if shmlog_size is > 0. shmlog_size is SHMLOG_SIZE by
+ * default on development versions, and 0 on release versions. If it is
+ * not > 0, the user has turned it off, so let's close the logbuffer. */
+ if (shmlog_size > 0 && logbuffer == NULL)
+ open_logbuffer();
+ else if (shmlog_size <= 0 && logbuffer)
+ close_logbuffer();
+ atexit(purge_zerobyte_logfile);
+}
+
+/*
+ * Opens the logbuffer.
+ *
+ */
+void open_logbuffer(void) {
+ /* Reserve 1% of the RAM for the logfile, but at max 25 MiB.
+ * For 512 MiB of RAM this will lead to a 5 MiB log buffer.
+ * At the moment (2011-12-10), no testcase leads to an i3 log
+ * of more than ~ 600 KiB. */
+ logbuffer_size = min(physical_mem_bytes * 0.01, shmlog_size);