"monthd" doesn't terminate

Ross Johnson ross at cancol.oz
Fri Nov 18 00:12:53 AEST 1988


In article <115 at cancol.oz>, ross at cancol.oz (Ross Johnson) writes:
> In article <1252 at leah.Albany.Edu>, rds95 at leah.Albany.Edu (Robert Seals) writes:
> > Specifically, it should go away after the user logs out, and it
> > doesn't.
> > 
> I've experienced the same thing on a Sun running OS3.2 (for cross-reference).

(I think this applies to BSD systems in general but I don't know about SYS5.)
This works for Sun OS3.2.

Monthd knows it won't get any signal to die at logout (because monthd spawns
an orphan child which gets inherited by init) so it attempts to find
out at it's regular awakening if the user has logged out. For non SYS5 systems
it assumes that doing a getpgrp(0) will return 0 if this is so but it isn't.

Instead, I do a getpgrp(parent_pid) and look for an error return of -1.
Because monthd sets parent_pid = getppid() before the fork it's the pid of
the login shell - which will disappear at logout. I've removed the setpgrp()
call as well.

This only works if you really logout as different from using "login" (to
someone else) in your current shell. The later uses the same shell process
before and after (and hence the same pid) but presumably you logout
eventually :-).

Here's the context diff:

*** monthd.c.dist	Thu Nov 17 13:39:31 1988
--- monthd.c	Thu Nov 17 23:10:01 1988
***************
*** 65,73 ****
--- 65,75 ----
  #ifdef hpux
  	    setpgrp2(0, parent_pid);
  #else
+ #ifdef SYS5
  	    setpgrp(0, parent_pid);
  #endif
  #endif
+ #endif
  	    inf_loop();
  	}
  
***************
*** 216,228 ****
  
  logged_out()
  {
  	/*
  	fprintf(tty, "%s: child pgrp = %d\n", prog_name, getpgrp());
  	*/
- #if SYS5
  	return(getpgrp() == 0);	/* pgrp is 0 after logout */
  #else
! 	return(getpgrp(0) == 0);/* pgrp is 0 after logout */
  #endif
  }
  
--- 218,233 ----
  
  logged_out()
  {
+ #if SYS5
  	/*
  	fprintf(tty, "%s: child pgrp = %d\n", prog_name, getpgrp());
  	*/
  	return(getpgrp() == 0);	/* pgrp is 0 after logout */
  #else
! /*
! 	fprintf(tty, "%s: -csh pgrp = %d\n", prog_name, getpgrp(parent_pid));
! */
! 	return(getpgrp(parent_pid) == -1);	/* is -csh still around? */
  #endif
  }
  



More information about the Comp.sources.bugs mailing list