Skip to content

Instantly share code, notes, and snippets.

@tctony
Forked from avdi/emacs-pidfile.el
Created July 25, 2017 15:21
Show Gist options
  • Select an option

  • Save tctony/f31cf7e8078654690445c1002fa40a26 to your computer and use it in GitHub Desktop.

Select an option

Save tctony/f31cf7e8078654690445c1002fa40a26 to your computer and use it in GitHub Desktop.
Write pidfile on emacs-server startup
(setq pidfile "emacs-server.pid")
(add-hook 'emacs-startup-hook
(lambda ()
(with-temp-file pidfile
(insert (number-to-string (emacs-pid))))))
(add-hook 'kill-emacs-hook
(lambda ()
(when (file-exists-p pidfile)
(delete-file pidfile))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment