]> git.sur5r.net Git - i3/i3/blobdiff - src/main.c
cleanup temporary directory when restarting and not using XDG_RUNTIME_DIR
[i3/i3] / src / main.c
index 4081c234430e1651df97ee58521a2a616b5dd21d..9a3063889d5958374e6ac5618a51a8a341120bf0 100644 (file)
@@ -18,6 +18,7 @@
 #include <sys/resource.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
+#include <libgen.h>
 #include "all.h"
 #include "shmlog.h"
 
@@ -670,8 +671,13 @@ int main(int argc, char *argv[]) {
     if (layout_path) {
         LOG("Trying to restore the layout from %s...", layout_path);
         needs_tree_init = !tree_restore(layout_path, greply);
-        if (delete_layout_path)
+        if (delete_layout_path) {
             unlink(layout_path);
+            const char *dir = dirname(layout_path);
+            /* possibly fails with ENOTEMPTY if there are files (or
+             * sockets) left. */
+            rmdir(dir);
+        }
         free(layout_path);
     }
     if (needs_tree_init)