Subject: kern/1560: compat_sunos doesn't have a vhangup()
To: None <gnats-bugs@gnats.netbsd.org>
From: None <mrg@eterna.com.au>
List: netbsd-bugs
Date: 10/02/1995 00:35:40
>Number:         1560
>Category:       kern
>Synopsis:       compat_sunos doesn't have a vhangup()
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct  2 15:50:39 1995
>Last-Modified:
>Originator:     matthew green
>Organization:
bozotic softwar foundation
>Release:        sep 30 '95
>Environment:
System: NetBSD splode.eterna.com.au 1.0A NetBSD 1.0A (_splode_) #254: Wed Sep 27 02:39:05 EST 1995 mrg@splode.eterna.com.au:/orb/q/build/src/sys/arch/sparc/compile/_splode_ sparc


>Description:

	the compat_sunos (and, incidentaly, osf1, linux, svr4 and ultrix)
	does not have a working vhangup() syscall emulation.  patch below
	provides this.

>How-To-Repeat:
>Fix:

	i've done what the sunos 4 and sunos 5 man pages say vhangup does:
	revoking access to the ctty of the calling process, to all processes,
	and, then sending a SIGHUP to the process group of the ctty.

	there is similar code in exit1() that does the hup first, then a
	ttywait() and then the vgoneall().  i implimented them with the
	vgoneall() first here because that's what the manual pages describes.
	i haven't called ttywait() because i'm unsure whether or not it is
	needed here.

	the osf1, linux, svr4 and ultrix compat modules could probably use
	this patch almost directly, as none of these impliment a vhangup()
	syscall either.

	this hasn't been tested, either, though, it does compile  :-)

	i don't have a sunos program that uses vhangup handy that actually
	works (in.telnetd was my attempt...).


Index: sunos_misc.c
===================================================================
RCS file: /local/cvs/src/sys/compat/sunos/sunos_misc.c,v
retrieving revision 1.6
diff -c -r1.6 sunos_misc.c
*** sunos_misc.c	1995/10/01 02:52:15	1.6
--- sunos_misc.c	1995/10/01 13:40:21
***************
*** 74,79 ****
--- 74,80 ----
  #include <sys/signal.h>
  #include <sys/signalvar.h>
  #include <sys/socket.h>
+ #include <sys/tty.h>
  #include <sys/vnode.h>
  #include <sys/uio.h>
  #include <sys/wait.h>
***************
*** 736,746 ****
  }
  
  int
! sunos_vhangup(p, uap, retval)
  	struct proc *p;
! 	void *uap;
  	register_t *retval;
  {
  	return 0;
  }
  
--- 737,757 ----
  }
  
  int
! sunos_vhangup(p, v, retval)
  	struct proc *p;
! 	void *v;
  	register_t *retval;
  {
+ 	struct sunos_vhangup_args *uap = v;
+ 	struct session *sp = p->p_session;
+ 
+ 	if (sp->s_ttyvp)
+ 		vgoneall(sp->s_ttyvp);
+ 	if (sp->s_ttyp && sp->s_ttyp->t_pgrp)
+ 		pgsignal(sp->s_ttyp->t_pgrp, SIGHUP, 1);
+ #if 0 /* kern_exit.c does the ttywait.  should we here ? */
+ 	(void) ttywait(sp->s_ttyp);
+ #endif
  	return 0;
  }
  
>Audit-Trail:
>Unformatted: