Proper way to detach from control terminal?

Tim Northrup tim at brspyr1.BRS.Com
Sat Jan 28 07:45:28 AEST 1989


I would like to know if there is a "proper" way to detach a process from
its   control   terminal  (once  it  has  fork'ed  and  the  parent  has
terminated).  I have seen a couple of different ways of doing  this  and
would  like  to  know  which  ones  work,  which don't, if there are any
others, and which is the correct way to do it.

Here are the methods I have seen:

	1.  setpgrp(2)

                This  is  the  method  described in the System V section
                termio(7), and does seem to work.  The calling  sequence
                I  am  using  is  simply  setpgrp()  for  System  V  and
                setpgrp(0,getpid()) for BSD based  code.   But,  on  BSD
                systems,  the  control terminal is still reported when a
                ps(1) is done.  Under  System  V,  the  control  tty  is
                listed  as  '?', as I would expect.  Is there any way to
                get this behavior under BSD?

	2.  ioctl(...TIOCSPGRP...)

		Is using ioctl to set the process group any different
		than using the setpgrp() system call?

	3.  ioctl(...TIOCNOTTY...)

		I have seen this used in the recently posted plp
		software, but cannot find any documentation on this
		setting other than "void tty association" in the
		header file <sys/ioctl.h> on a BSD system.

	4.  closing all terminal files

                I  don't know if I am reading things wrong, but it seems
                that some programs simple close  stdin/stdout/stderr  on
                startup  and  open  something  else as stdin.  Does this
                really do anything?  Should I do this  in  concert  with
                any/all of the above options?

Thanks in advance for any assistence.
							-- Tim
-- 
Tim Northrup      		  +------------------------------------------+
+---------------------------------+         GEnie:  T.Northrup               |
UUCP: uunet!steinmetz!brspyr1!tim |   Air Warrior:  "Duke"                   |
ARPA: tim at brspyr1.BRS.Com	  +------------------------------------------+



More information about the Comp.unix.wizards mailing list