[comp.emacs] faster way to "ps lct"

mkhaw@teknowledge-vaxc.ARPA (Michael Khaw) (04/09/87)

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

drw@cullvax.UUCP (04/09/87)

mkhaw@teknowledge-vaxc.ARPA (Michael Khaw) writes:
> 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.

There's probably a good reason why you don't do this, but why don't
you rebind C-x C-z to save-buffers-kill-emacs?  This still leaves C-z
for suspend-emacs.

Dale
-- 
Dale Worley		Cullinet Software
UUCP: ...!seismo!harvard!mit-eddie!cullvax!drw
ARPA: cullvax!drw@eddie.mit.edu
Un*x (a generic name for a class of OS's) != Unix (AT&T's brand of such)

steiner@topaz.UUCP (04/09/87)

We were having the same problem with our users.  We just disabled
suspend-emacs in our site-init.elc.  We assumed that once the person
has actually re-enabled suspend-emacs they (sort-of) knew what they
were doing.  This method seems to work for about 95-99% of the users.

ds
-- 

uucp:  ...{harvard, seismo, ut-sally, ihnp4!packard}!rutgers!topaz!steiner
arpa:  Steiner@TOPAZ.RUTGERS.EDU

tim@ism780c.UUCP (04/18/87)

In an article, Michael Khaw writes:
< 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.
.
< The only way I've found to do the trick is to popen("/bin/ps lct", "r"), and
[ he says that this is too slow ]

How about having emacs maintain a file in /tmp for each user that
contains the pid and ppid of each running emacs? 

At startup, it could check the file, and then add an entry for itself.
When it exits, it can remove that entry..

-- 
Tim Smith			"Hojotoho! Hojotoho!
uucp: sdcrdcf!ism780c!tim	 Heiaha! Heiaha!
Delph or GEnie: Mnementh	 Hojotoho! Heiaha!"
Compuserve: 72257,3706