jbw@BIGBIRD.BU.EDU (Joe Wells) (12/20/90)
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$$") (goto-char (point-min)) (let (case-fold-search) (re-search-forward "[ \t]+PID") (let ((col (current-column))) (forward-line 1) (move-to-column col)) (read (current-buffer)))) -- Enjoy, Joe Wells <jbw@bu.edu>
hugh@EAR.MIT.EDU (Hugh Secker-Walker) (01/03/91)
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