]> git.sur5r.net Git - i3/i3/commitdiff
delete ipc socket when exiting, cleanup tmpdir
authorMichael Stapelberg <michael@stapelberg.de>
Sun, 8 Jun 2014 20:13:43 +0000 (22:13 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Sun, 8 Jun 2014 20:13:43 +0000 (22:13 +0200)
fixes #1253

src/commands.c
src/main.c
testcases/t/229-cleanup-tmpdir.t [new file with mode: 0644]

index 801c93063a0346932b080cf888bbbc5f8ac9cbcb..81358274b1ebf6f3979e2c5bbca97570115d3b14 100644 (file)
@@ -1649,6 +1649,8 @@ void cmd_layout_toggle(I3_CMD, char *toggle_mode) {
  */
 void cmd_exit(I3_CMD) {
     LOG("Exiting due to user command.\n");
+    ipc_shutdown();
+    unlink(config.ipc_socket_path);
     xcb_disconnect(conn);
     exit(0);
 
index 5ff9afe023bda9f17e0cff6b61515838d0afdbb4..4081c234430e1651df97ee58521a2a616b5dd21d 100644 (file)
@@ -722,7 +722,6 @@ int main(int argc, char *argv[]) {
     if (ipc_socket == -1) {
         ELOG("Could not create the IPC socket, IPC disabled\n");
     } else {
-        free(config.ipc_socket_path);
         struct ev_io *ipc_io = scalloc(sizeof(struct ev_io));
         ev_io_init(ipc_io, ipc_new_client, ipc_socket, EV_READ);
         ev_io_start(main_loop, ipc_io);
diff --git a/testcases/t/229-cleanup-tmpdir.t b/testcases/t/229-cleanup-tmpdir.t
new file mode 100644 (file)
index 0000000..6448da0
--- /dev/null
@@ -0,0 +1,53 @@
+#!perl
+# vim:ts=4:sw=4:expandtab
+#
+# Please read the following documents before working on tests:
+# • http://build.i3wm.org/docs/testsuite.html
+#   (or docs/testsuite)
+#
+# • http://build.i3wm.org/docs/lib-i3test.html
+#   (alternatively: perldoc ./testcases/lib/i3test.pm)
+#
+# • http://build.i3wm.org/docs/ipc.html
+#   (or docs/ipc)
+#
+# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
+#   (unless you are already familiar with Perl)
+#
+# Makes sure i3 deletes its temporary directory when exiting.
+# Ticket: #1253
+# Bug still in: 4.7.2-186-g617afc6
+use i3test i3_autostart => 0;
+use File::Basename;
+
+my $config = <<EOT;
+# i3 config file (v4)
+font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
+EOT
+
+# ensure XDG_RUNTIME_DIR is not set
+delete $ENV{XDG_RUNTIME_DIR};
+
+my $pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1);
+my $socketpath = get_socket_path(0);
+my $tmpdir = dirname($socketpath);
+
+ok(-d $tmpdir, "tmpdir $tmpdir exists");
+
+# Clear the error logfile. The testsuite runs in an environment where RandR is
+# not supported, so there always is a message about xinerama in the error
+# logfile.
+my @errorlogfiles = <$tmpdir/errorlog.*>;
+for my $fn (@errorlogfiles) {
+    open(my $fh, '>', $fn);
+    close($fh);
+}
+
+exit_gracefully($pid);
+
+ok(! -d $tmpdir, "tmpdir $tmpdir was cleaned up");
+if (-d $tmpdir) {
+    diag('contents = ' . Dumper(<$tmpdir/*>));
+}
+
+done_testing;