From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#44644: /tmp/emacs0/ not cleaned up upon exit Date: Tue, 24 Nov 2020 17:28:09 +0200 Message-ID: <83y2iqu646.fsf@gnu.org> References: <87a6vjk9ep.8.fsf@jidanni.org> <87y2j0sxz0.fsf@gnus.org> <83zh3gqb9o.fsf@gnu.org> <87sg8zcnu0.fsf@gnus.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33090"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 44644@debbugs.gnu.org, jidanni@jidanni.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 24 16:29:10 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1khaFi-0008V4-Ms for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 24 Nov 2020 16:29:10 +0100 Original-Received: from localhost ([::1]:36738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khaFh-0002Ke-IM for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 24 Nov 2020 10:29:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khaFa-0002Jl-Ms for bug-gnu-emacs@gnu.org; Tue, 24 Nov 2020 10:29:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49383) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1khaFa-0001tU-Fp for bug-gnu-emacs@gnu.org; Tue, 24 Nov 2020 10:29:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1khaFa-0005GY-Cu for bug-gnu-emacs@gnu.org; Tue, 24 Nov 2020 10:29:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 24 Nov 2020 15:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44644 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 44644-submit@debbugs.gnu.org id=B44644.160623170020164 (code B ref 44644); Tue, 24 Nov 2020 15:29:02 +0000 Original-Received: (at 44644) by debbugs.gnu.org; 24 Nov 2020 15:28:20 +0000 Original-Received: from localhost ([127.0.0.1]:60926 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1khaEu-0005F9-1J for submit@debbugs.gnu.org; Tue, 24 Nov 2020 10:28:20 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:42212) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1khaEt-0005Ew-21 for 44644@debbugs.gnu.org; Tue, 24 Nov 2020 10:28:19 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:46005) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khaEn-0001om-Ct; Tue, 24 Nov 2020 10:28:13 -0500 Original-Received: from [176.228.60.248] (port=2660 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1khaEl-0006XR-4Q; Tue, 24 Nov 2020 10:28:12 -0500 In-Reply-To: <87sg8zcnu0.fsf@gnus.org> (message from Lars Ingebrigtsen on Tue, 24 Nov 2020 06:42:47 +0100) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:194076 Archived-At: > From: Lars Ingebrigtsen > Cc: jidanni@jidanni.org, 44644@debbugs.gnu.org > Date: Tue, 24 Nov 2020 06:42:47 +0100 > > Eli Zaretskii writes: > > >> True. Looking at the code, it looks like having `server-start' add > >> `server-force-delete' to `kill-emacs-query-functions' would do the > >> trick? > >> > >> Does anybody see any downsides to doing that? > > > > What if the Emacs that's being killed is not the one that created the > > server file? > > I didn't read the code closely enough -- emacs-server already does this, > but only deletes the /tmp/emacs0/server socket, but leaves the directory > behind. As you say, there may be more than one server (with different > names), so deleting the directory may fail, but the final Emacs that > exits should successfully delete directory, at least, and I've added > that to Emacs 28. Wait a moment: we are deleting the _directory_ of the server file? Sorry, I was confused and thought you were talking about the server file itself. The directory thing is different. First, its place and purpose depends on whether server-use-tcp is nil (Posix platforms) or not (MS-Windows or when the user of a Posix host connects from another system). If this is non-nil, the directory of the server file is server-auth-dir, which is: (defcustom server-auth-dir (locate-user-emacs-file "server/") Since this is a defcustom, I don't think we can delete that directory behind user's back, even if it is empty. If server-use-tcp is nil (the default), then the directory of server-file is computed thusly: (defvar server-socket-dir (if internal--daemon-sockname (file-name-directory internal--daemon-sockname) (and (featurep 'make-network-process '(:family local)) (let ((xdg_runtime_dir (getenv "XDG_RUNTIME_DIR"))) (if xdg_runtime_dir (format "%s/emacs" xdg_runtime_dir) (format "%s/emacs%d" (or (getenv "TMPDIR") "/tmp") (user-uid)))))) I don't think it's kosher to delete $XDG_RUNTIME_DIR, even if it's empty, since it is probably used by more than the server? And if XDG_RUNTIME_DIR is not defined, and we use a directory under /tmp, then the system cleans that up from time to time, doesn't it? So bottom line, I don't think we should do this, at least not unconditionally.