TIOCNOTTY under SCO System V/386

Chip Rosenthal chip at chinacat.unicom.com
Sat Jun 22 03:12:42 AEST 1991


In article <54 at jeanluc.UUCP> stockett at jeanluc.UUCP (Jeffrey M. Stockett) writes:
>I'm trying to port over some code from a BSD machine to SCO System V/386,
>and I have run into a problem with [TIOCNOTTY]

Following code is from Richard Steven's daemon_start() routine.  This
is all explained in his book `UNIX Network Programming'.  It's a good
book and Richard is a great guy - I think y'all should buy two or three
copies.  Sources are on UUNET in (I think) ~/networking/netprog.tar.Z.

	/*
	 * First child process.
	 *
	 * Disassociate from controlling terminal and process group.
	 * Ensure the process can't reacquire a new controlling terminal.
	 */

#ifdef	SIGTSTP		/* BSD */

	if (setpgrp(0, getpid()) == -1)
		err_sys("can't change process group");

	if ( (fd = open("/dev/tty", O_RDWR)) >= 0) {
		ioctl(fd, TIOCNOTTY, (char *)NULL); /* lose controlling tty */
		close(fd);
	}

#else	/* System V */

	if (setpgrp() == -1)
		err_sys("can't change process group");

	signal(SIGHUP, SIG_IGN);	/* immune from pgrp leader death */

	if ( (childpid = fork()) < 0)
		err_sys("can't fork second child");
	else if (childpid > 0)
		exit(0);	/* first child */

	/* second child */
#endif

-- 
Chip Rosenthal  512-482-8260  |  Closed user interfaces for open systems?
Unicom Systems Development    |  No, thank you.
<chip at chinacat.Unicom.COM>    |  Boycott Lotus Development Corp.



More information about the Comp.unix.sysv386 mailing list