[comp.windows.x] xtools not killing children

klong@pauling.tmc.edu (Kevin Long) (07/25/89)

We're having a problem with the xtools program not taking it's children
with it when we kill it after running on an NCD X terminal.

We have Suns running X11R3 on SunOS4.0.3, and use the xtools program when 
bringing up someone's environment, which makes all windows, window managers, 
and other various processes children of the xtools process, so that by 
killing a single process (i.e. clicking on the "quit" button on the xtools 
window), all processes are killed.

On our Suns, the X process itself is one of these children, and xtools works
fine--we quit it, and it takes everything with it.

On an NCD box, we're telnetting to one of our Sun hosts, and we're not running
X itself, since that's what the NCD box does in hardware.  So the only
difference is that we're not running that one X process.  ps shows that
all other windows are children of the xtools process, but when we quit xtools,
its window just hangs and everything else stays up and running fine.

We have heard a guess that the problem has to do with xtools' not being
able to get a list of the children pids it needs to kill them off, but it's
able to get them when I'm on the Sun directly, so I need *help*.

Has anyone else solved this problem?

Below is the xtools code that tries to kill off the children processes...
/*
 * shutdown is called when quitting.  it kills all outstanding
 * processes.
 */
static void
shutdown() {
	int		i, j;

	for (j = 0; j < SIGS; j++) {
		for (i = 0; i < npids; i++) {
			if (pids[i] == 0)
				continue;

			/*
			 * don't try to kill children that have
			 * already exited.
			 */
			if (getpgrp(pids[i]) == -1) {
				pids[i] = 0;
				continue;
			}

			if (killpg(pids[i], sigs[j]) == -1) {
				if (debug)
					(void) printf("can't kill pid %d\n",
						      pids[i]);
				continue;
			}
		}
	}

	dohang = 0;
	cleanup();

	exit(0);
}

--------
Hope someone can help.... sigh...
Please reply directly to me via email, as well as to the newsgroup if you
wish, since our news server is perpetually two weeks behind.

	Regards,
	Kevin Long
	IAIMS Development
	Baylor College of Medicine
	1 Baylor Plaza
	Houston, TX 77030
	(713) 798-6116
	klong@bcm.tmc.edu