Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-unix!teknowledge-vaxc!mkhaw From: mkhaw@teknowledge-vaxc.ARPA (Michael Khaw) Newsgroups: comp.emacs,comp.unix.questions,comp.unix.wizards Subject: faster way to "ps lct" (bsd4.x) from C? Message-ID: <11634@teknowledge-vaxc.ARPA> Date: Thu, 9-Apr-87 00:36:31 EST Article-I.D.: teknowle.11634 Posted: Thu Apr 9 00:36:31 1987 Date-Received: Mon, 13-Apr-87 04:02:50 EST Distribution: na Organization: Teknowledge, Inc., Palo Alto CA Lines: 31 Keywords: ps emacs pid ppid job control Xref: mnetor comp.emacs:838 comp.unix.questions:1870 comp.unix.wizards:1884 Because we have a lot of users who are accustomed to a local TOPS-20 version of Emacs that uses C-x C-z to exit emacs, many of them tend to leave lots of ^Z suspended gnu emacs on our Ultrix 1.2 VAX when they really mean to exit with C-x C-c. So, I want to modify emacs so it checks to see if its parent process has any other children that are emacs and tell the user about them. Just checking if the controlling terminal has other emacses is probably too obnoxious since we want to be nice if the user, for example, intentionally suspends emacs from the login shell and starts an emacs from mail. The only way I've found to do the trick is to popen("/bin/ps lct", "r"), and look for any process named "emacs" whose pid is not mine and whose ppid matches my ppid. However, on a busy system with many processes this takes several seconds, making emacs noticeably slower (than it already is) to fire up. I figure there must be a way to read /dev/kmem (?) directly to find out if my parent has any children who are emacs processes -- but I haven't found any place in the manuals that provide enough detail. The man page for nlist(3) and /usr/include/{a.out,nlist,stab}.h are wonderfully vague about just what I ought to pass as "nl" in nlist("/dev/kmem", nl), if in fact that would get me the information I need. Do I need to point out that we don't have source code? :( Thanks in advance, Mike Khaw -- internet: mkhaw@teknowledge-vaxc.arpa usenet: {hplabs|sun|ucbvax|decwrl|sri-unix}!mkhaw%teknowledge-vaxc.arpa USnail: Teknowledge Inc, 1850 Embarcadero Rd, POB 10119, Palo Alto, CA 94303