SysVR3.2 Setpgrp behaviour

Joe Konczal konczal at mail-gw.ncsl.nist.gov
Sat Oct 14 03:12:03 AEST 1989


>   It seems the "setpgrp" call behaves as designed and as per
>   documentaion. However if followed by a 'while' or 'for' (finite or
>   infinite) loop it will not detach a process from the controlling
>   tty. I've tried both...

I looked at the source for a BSD 4.3 daemon to see how it detaches from 
the controlling terminal and came up with this code fragment which works 
in SunOS 4.0.  Is there anything similar to this in System V?

  int fd;

  if ((fd = open("/dev/tty", 2)) < 0)		  /* detach process
						     from terminal */ 
    error("open /dev/tty");
  else {
      if (ioctl(fd, (int) TIOCNOTTY, (char *) 0) < 0) 
	error("ioctl TIOCNOTTY");
      close(fd);
    }
  setpgrp(0, 0);


Joe Konczal



More information about the Comp.unix.wizards mailing list