From 3802f9ce3d5ff72fc73406528c90bd6e265231ab Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 24 Nov 2020 06:41:03 +0100 Subject: [PATCH] Delete the emacs-server directory upon Emacs exit * lisp/server.el (server-start): Delete the server directory upon Emacs exit (bug#44644). This fixes the problem of /tmp/emacs0 directories being left behind when running an Emacs server as root. --- lisp/server.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/server.el b/lisp/server.el index 763f651fefc..1219b021224 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -648,7 +648,12 @@ the `server-process' variable." ;; Remove any leftover socket or authentication file. (ignore-errors (let (delete-by-moving-to-trash) - (delete-file server-file))) + (delete-file server-file) + ;; Also delete the directory that the server file was + ;; created in. There may be other servers running, + ;; too, so this may fail. + (ignore-errors + (delete-directory (file-name-directory server-file))))) (setq server-mode nil) ;; already set by the minor mode code (display-warning 'server -- 2.39.2