[comp.unix.questions] TIOCNOTTY definition

VENENGA@iscsvax.uni.edu (05/29/91)

I am trying to convert some bsd source to SYS V, and overall, it's not going
too bad.  The only problem I am running into is a TIOCNOTTY not defined
compiler error.  I have grep'ped all my include files, and cannot find a
TIOCNOTTY definition anywhere.  Could some kind soul(s) tell me what this
should be defined as?  Thanks.

===========================================================================
Jay Venenga                              Internet: venenga@uni.edu
Systems Programmer                             or: venenga@iscsvax.uni.edu
Information Systems and Computing Services
University of Northern Iowa             USWestNet: (319) 273-2008
Cedar Falls, IA  50614-0509                   FAX: (319) 273-3509
===========================================================================

dkeisen@leland.Stanford.EDU (Dave Eisen) (05/30/91)

In article <27046@adm.brl.mil> VENENGA@iscsvax.uni.edu writes:
>I am trying to convert some bsd source to SYS V, and overall, it's not going
>too bad.  The only problem I am running into is a TIOCNOTTY not defined
>compiler error.  I have grep'ped all my include files, and cannot find a
>TIOCNOTTY definition anywhere.  Could some kind soul(s) tell me what this

A define for TIOCNOTTY would not be of any use to you anyway. The fact that
TIOCNOTTY is not in termio.h means that the terminal driver doesn't support
this ioctl, which is in fact unique to BSD-like systems. 

This is usually used on a file descriptor obtained by opening /dev/tty in
order for the calling process to disassociate itself with the control
terminal (so it won't receive signals when a user hits the interrupt
key, etc.). In System Vish systems the way to disassociate from the
control terminal is to change your process group using the call setpgrp.

So replace the opening /dev/tty, doing that ioctl, and closing the
descriptor with a call to setpgrp.

Caveat: If the process later opens up a terminal device file, that becomes
the control terminal for the process and you lose the protection you just 
got by calling setpgrp. There are ways to deal with this, for a 
good discussion of the issues that arise when setting up a daemon, I
recommend Richard Stevens's book on UNIX Network Programming.



-- 
Dave Eisen                           dkeisen@leland.Stanford.EDU
1101 San Antonio Road, Suite 102     (Gang-of-Four is being taken off the net)
Mountain View, CA 94043
(415) 967-5644

mouse@thunder.mcrcim.mcgill.edu (der Mouse) (06/02/91)

In article <27046@adm.brl.mil>, VENENGA@iscsvax.uni.edu writes:

> I am trying to convert some bsd source to SYS V, and overall, it's
> not going too bad[ly].  The only problem I am running into is a
> TIOCNOTTY not defined compiler error.  I have grep'ped all my include
> files, and cannot find a TIOCNOTTY definition anywhere.  Could some
> kind soul(s) tell me what this should be defined as?

If you don't have the definition, you all but certainly don't have
support for it in your kernel, and a definition would do you no good at
all.  If you really really want to try it anyway, the value on our
system is 0x20007471, and the definition (which may not be compatible
with your include files' ioctl() defines, which is why I gave the
value) is

#define	TIOCNOTTY	_IO(t, 113)	/* void tty association */

On SysV, the function performed by TIOCNOTTY is, sort of, performed by
setpgrp().  I think.  (That function being to break the association
between a process and its control tty.)

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu