Xref: utzoo gnu.emacs.help:692 comp.emacs:9805 Path: utzoo!utgpu!watserv1!watmath!uunet!tut.cis.ohio-state.edu!EAR.MIT.EDU!hugh From: hugh@EAR.MIT.EDU (Hugh Secker-Walker) Newsgroups: gnu.emacs.help,comp.emacs Subject: Process ID of Emacs Message-ID: <9101021829.AA08679@ear.MIT.EDU> Date: 2 Jan 91 18:29:47 GMT References: <9012200058.AA10086@bigbird.bu.edu> Sender: daemon@tut.cis.ohio-state.edu Followup-To: gnu.emacs.help Organization: Gatewayed from the GNU Project mailing list help-gnu-emacs@prep.ai.mit.edu Lines: 27 Is there a function or variable that returns the Un*x process id of the running emacs? No, but something like this will do what you want on most systems: (save-excursion (set-buffer (get-buffer-create "*Emacs PID*")) (erase-buffer) (call-process "/bin/sh" nil t nil "-c" "ps -l$$") .... Thanks for this idea. I had thought about having emacs call a process that printed the result of a call to getppid(2). Someone sent me code which creates, compiles, and then runs such a program. The hard-core generalist in me says that there should always be an emacs (sub)process, called "self" which is the running emacs. Various of the process handling procedures could use this process, e.g. (process-id (get-process "self")). However, one can waste inordinate amounts of time trying to generalize obscure needs. Hugh