Skip to content

Instantly share code, notes, and snippets.

@darrik
Created August 1, 2014 20:26
Show Gist options
  • Save darrik/c0f7995fb0bcaadab942 to your computer and use it in GitHub Desktop.
Save darrik/c0f7995fb0bcaadab942 to your computer and use it in GitHub Desktop.
(defun darrik/isrunning-p (argv)
"Return `t' if `argv' is running."
(or (listp argv)
(setq argv (list argv)))
(dolist (pid (list-system-processes))
(let* ((pdata (process-attributes pid))
(x (assoc 'comm pdata))
(exe (cdr x)))
(when (member exe argv)
(return t)))))
@darrik
Copy link
Author

darrik commented Aug 1, 2014

(darrik/isrunning-p "emacs") ; t
(darrik/isrunning-p '("emacs")) ; t
(darrik/isrunning-p '("emac")) ; nil
(darrik/isrunning-p '("emac" "zsh")) ; t

Don't forget to add ".exe" if you're on Windows.
(darrik/isrunning-p "emacs.exe") ; t

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment