Subject: bug#1474: 23.0.60; desktop.el don't check if pid in his lock file is always in use

From: Eli Zaretskii <[email-masked]>
Date: Mon, 27 Apr 2020 17:50:09 +0300

> From: Stefan Kangas <[email-masked]>
> Cc: [email-masked],  [email-masked],  [email-masked]
> Date: Mon, 27 Apr 2020 12:34:08 +0200
> 
> >> +(defun desktop--emacs-pid-running-p (pid)
> >> +  "Return t if an Emacs process with PID exists."
> >> +  (when-let ((attr (process-attributes pid)))
> >> +    (string-match "^emacs$" (alist-get 'comm attr))))
> >
> > I understand the rationale for the string-match test, but what if the
> > executable file name of Emacs was "transformed", per the
> > '--program-transform-name' option of the configure script?  And even
> > if it wasn't transformed, this will not match emacs-XX.YY and
> > emacs.exe.
> 
> Good point.  But would you suggest to use no check at all, or is there
> some other check we could reasonably use?  I assume it is impossible
> to use the process name due to '--program-transform-name'.

Perhaps you could use the name you find in command-line-args?  Note
that it might include leading directories, and at least on Windows the
directory separator might either be a slash or a backslash, so use of
file-name-nondirectory is advised.