[459] in Zephyr_Bugs
zwgc patch so that it will die upon logout on HPUX machines.
daemon@ATHENA.MIT.EDU (Scott Dawson)
Wed Mar 3 21:36:27 1993
To: zephyr-bugs@Athena.MIT.EDU
Cc: sdawson@engin.umich.edu
Date: Wed, 03 Mar 93 16:25:40 -0500
From: Scott Dawson <sdawson@engin.umich.edu>
Hi. As promised, here's a patch which will cause zwgc to die when you
log out of an HPUX machine. This is superior to simply having zwgc
put itself in it's parent's process group because you it still works
if you run it several levels deep in cshs and your parent isn't your
session leader.
I know you guys might not support hpux, but you might find this
useful if you ever do or if anyone else is trying to run this stuff on
hpux and asks you about it.
I am going to look into a better way to accomplish this on AIX, but I
don't know if there is one.
-Scott
apply this patch in src/zwgc.
*** /tmp/RCSAa01211 Wed Mar 3 15:24:39 1993
--- main.c Wed Mar 3 15:24:24 1993
***************
*** 35,40 ****
--- 35,44 ----
#include "variables.h"
#include "main.h"
+ #ifdef hpux
+ #include <sys/pstat.h> /* for finding of session leader */
+ #endif
+
extern void notice_handler();
static void setup_signals(), detach();
***************
*** 400,407 ****
#ifdef _AIX
(void) setpgid(0, getpgrp(getppid()));
#else
(void) setpgrp(0, getpgrp(getppid()));
! #endif
/* fork off and let parent exit... */
if (i = fork()) {
if (i < 0) {
--- 404,430 ----
#ifdef _AIX
(void) setpgid(0, getpgrp(getppid()));
#else
+ #ifdef hpux
+ struct pst_status p;
+ int oldpid, curpid=getpid(), found=0;
+
+ /* walk a ppid chain until we cross the session boundary. At this
+ * point, we know that the last pid checked was the session leader.
+ * We then put ourselves in the process group of the session leader
+ * to ensure that we will get a HUP when the user logs out. */
+
+ while(!found){
+ (void)pstat(PSTAT_PROC,&p,sizeof(struct pst_status),0,curpid);
+ oldpid=curpid;
+ curpid=p.pst_ppid;
+ if(getpgrp2(curpid) < 0) found=1;
+ }
+
+ setpgid(0,getpgrp2(oldpid));
+ #else
(void) setpgrp(0, getpgrp(getppid()));
! #endif /* hpux */
! #endif /* _AIX */
/* fork off and let parent exit... */
if (i = fork()) {
if (i < 0) {