TRACE(("spawn TIOCSWINSZ %dx%d return %d\n", ws.ws_row, ws.ws_col, i))
TRACE(("spawn TIOCSWINSZ %dx%d return %d\n", ws.ws_row, ws.ws_col, i));
spawn (void)/* *  Inits pty and tty and forks a login process. *  Does not close fd Xsocket. *  If slave, the pty named in passedPty is already open for use */{	register TScreen *screen = &term->screen;#ifdef USE_HANDSHAKE	handshake_t handshake;#endif#if OPT_INITIAL_ERASE	int initial_erase = VAL_INITIAL_ERASE;#endif	int tty = -1;	int done;#ifdef USE_SYSV_TERMIO	struct termio tio;#ifdef TIOCLSET	unsigned lmode;#endif	/* TIOCLSET */#ifdef HAS_LTCHARS	struct ltchars ltc;#endif	/* HAS_LTCHARS */#elif defined(USE_POSIX_TERMIOS)	struct termios tio;#else /* !USE_SYSV_TERMIO && !USE_POSIX_TERMIOS */	int ldisc = 0;	int discipline;	unsigned lmode;	struct tchars tc;	struct ltchars ltc;	struct sgttyb sg;#ifdef sony	int jmode;	struct jtchars jtc;#endif /* sony */#endif	/* USE_SYSV_TERMIO */	char termcap [1024];	char newtc [1024];	char *ptr, *shname, *shname_minus;	int i, no_dev_tty = FALSE;	char **envnew;		/* new environment */	int envsize;		/* elements in new environment */	char buf[64];	char *TermName = NULL;#if defined(TIOCSSIZE) && (defined(sun) && !defined(SVR4))	struct ttysize ts;#elif defined(TIOCSWINSZ)	struct winsize ws;#endif	struct passwd *pw = NULL;#ifdef UTMP#if (defined(SVR4) || defined(SCO325)) && !defined(__CYGWIN__)	struct utmpx utmp;#else	struct utmp utmp;#endif#ifdef LASTLOG	struct lastlog lastlog;#endif	/* LASTLOG */#endif	/* UTMP */	screen->uid = getuid();	screen->gid = getgid();	termcap[0] = '\0';	newtc[0] = '\0';#ifdef SIGTTOU	/* so that TIOCSWINSZ || TIOCSIZE doesn't block */	signal(SIGTTOU,SIG_IGN);#endif	if (am_slave) {		screen->respond = am_slave;#ifndef __osf__		ptydev[strlen(ptydev) - 2] = ttydev[strlen(ttydev) - 2] =			passedPty[0];		ptydev[strlen(ptydev) - 1] = ttydev[strlen(ttydev) - 1] =			passedPty[1];#endif /* __osf__ */		setgid (screen->gid);		setuid (screen->uid);	} else {		Bool tty_got_hung;		/*		 * Sometimes /dev/tty hangs on open (as in the case of a pty		 * that has gone away).  Simply make up some reasonable		 * defaults.		 */		signal(SIGALRM, hungtty);		alarm(2);		/* alarm(1) might return too soon */                if (! sigsetjmp(env, 1)) {			tty = open ("/dev/tty", O_RDWR, 0);			alarm(0);			tty_got_hung = False;		} else {			tty_got_hung = True;			tty = -1;			errno = ENXIO;		}#if OPT_INITIAL_ERASE		initial_erase = VAL_INITIAL_ERASE;#endif		signal(SIGALRM, SIG_DFL);		/*		 * Check results and ignore current control terminal if		 * necessary.  ENXIO is what is normally returned if there is		 * no controlling terminal, but some systems (e.g. SunOS 4.0)		 * seem to return EIO.  Solaris 2.3 is said to return EINVAL.		 */		no_dev_tty = FALSE;		if (tty < 0) {			if (tty_got_hung || errno == ENXIO || errno == EIO ||			    errno == EINVAL || errno == ENOTTY) {				no_dev_tty = TRUE;#ifdef HAS_LTCHARS				ltc = d_ltc;#endif	/* HAS_LTCHARS */#ifdef TIOCLSET				lmode = d_lmode;#endif	/* TIOCLSET */#if defined(USE_SYSV_TERMIO) || defined(USE_POSIX_TERMIOS)				tio = d_tio;#else	/* not USE_SYSV_TERMIO and not USE_POSIX_TERMIOS */				sg = d_sg;				tc = d_tc;				discipline = d_disipline;#ifdef sony				jmode = d_jmode;				jtc = d_jtc;#endif /* sony */#endif	/* USE_SYSV_TERMIO or USE_POSIX_TERMIOS */			} else {			    SysError(ERROR_OPDEVTTY);			}		} else {			/* Get a copy of the current terminal's state,			 * if we can.  Some systems (e.g., SVR4 and MacII)			 * may not have a controlling terminal at this point			 * if started directly from xdm or xinit,			 * in which case we just use the defaults as above.			 */#ifdef HAS_LTCHARS			if(ioctl(tty, TIOCGLTC, &ltc) == -1)				ltc = d_ltc;#endif	/* HAS_LTCHARS */#ifdef TIOCLSET			if(ioctl(tty, TIOCLGET, &lmode) == -1)				lmode = d_lmode;#endif	/* TIOCLSET */#ifdef USE_SYSV_TERMIO		        if(ioctl(tty, TCGETA, &tio) == -1)			        tio = d_tio;#elif defined(USE_POSIX_TERMIOS)			if (tcgetattr(tty, &tio) == -1)			        tio = d_tio;#else   /* !USE_SYSV_TERMIO && !USE_POSIX_TERMIOS */			if(ioctl(tty, TIOCGETP, (char *)&sg) == -1)			        sg = d_sg;			if(ioctl(tty, TIOCGETC, (char *)&tc) == -1)			        tc = d_tc;			if(ioctl(tty, TIOCGETD, (char *)&discipline) == -1)			        discipline = d_disipline;#ifdef sony			if(ioctl(tty, TIOCKGET, (char *)&jmode) == -1)			        jmode = d_jmode;			if(ioctl(tty, TIOCKGETC, (char *)&jtc) == -1)				jtc = d_jtc;#endif /* sony */#endif	/* USE_SYSV_TERMIO */#if OPT_INITIAL_ERASE			if (resource.ptyInitialErase) {#ifdef USE_SYSV_TERMIO				initial_erase = tio.c_cc[VERASE];#elif defined(USE_POSIX_TERMIOS)				initial_erase = tio.c_cc[VERASE];#else   /* !USE_SYSV_TERMIO && !USE_POSIX_TERMIOS */				initial_erase = sg.sg_erase;#endif	/* USE_SYSV_TERMIO */			}			if (resource.backarrow_is_erase) 			if (initial_erase == 127) {	/* see input.c */				term->keyboard.flags &= ~MODE_DECBKM;			}#endif#ifdef MINIX			/* Editing shells interfere with xterms started in			 * the background.			 */			tio = d_tio;#endif			close (tty);			/* tty is no longer an open fd! */			tty = -1;		}#ifdef 	PUCC_PTYD		if(-1 == (screen->respond = openrpty(ttydev, ptydev,				(resource.utmpInhibit ?  OPTY_NOP : OPTY_LOGIN),				getuid(), XDisplayString(screen->display))))#else /* not PUCC_PTYD */		if (get_pty (&screen->respond))#endif /* PUCC_PTYD */		{			/*  no ptys! */			(void) fprintf(stderr, "%s: no available ptys\n",				       xterm_name);			exit (ERROR_PTYS);		}#ifdef PUCC_PTYD		  else {			/*			 *  set the fd of the master in a global var so			 *  we can undo all this on exit			 *			 */			Ptyfd = screen->respond;		  }#endif /* PUCC_PTYD */	}	/* avoid double MapWindow requests */	XtSetMappedWhenManaged(XtParent(CURRENT_EMU(screen)), False );	wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW",				       False);	if (!TEK4014_ACTIVE(screen))	    VTInit();		/* realize now so know window size for tty driver */#if defined(TIOCCONS) || defined(SRIOCSREDIR)	if (Console) {	    /*	     * Inform any running xconsole program	     * that we are going to steal the console.	     */	    XmuGetHostname (mit_console_name + MIT_CONSOLE_LEN, 255);	    mit_console = XInternAtom(screen->display, mit_console_name, False);	    /* the user told us to be the console, so we can use CurrentTime */	    XtOwnSelection(XtParent(CURRENT_EMU(screen)),			   mit_console, CurrentTime,			   ConvertConsoleSelection, NULL, NULL);	}#endif#if OPT_TEK4014	if(screen->TekEmu) {		envnew = tekterm;		ptr = newtc;	}	else#endif	{		envnew = vtterm;		ptr = termcap;	}	/*	 * This used to exit if no termcap entry was found for the specified	 * terminal name.  That's a little unfriendly, so instead we'll allow	 * the program to proceed (but not to set $TERMCAP) if the termcap	 * entry is not found.	 */	*ptr = 0;	/* initialize, in case we're using terminfo's tgetent */	TermName = NULL;	if (resource.term_name) {	    TermName = resource.term_name;	    if (tgetent (ptr, resource.term_name) == 1) {		if (*ptr)		    if (!TEK4014_ACTIVE(screen))			resize (screen, termcap, newtc);	    }	}	/*	 * This block is invoked only if there was no terminal name specified	 * by the command-line option "-tn".	 */	if (!TermName) {	    TermName = *envnew;	    while (*envnew != NULL) {		if(tgetent(ptr, *envnew) == 1) {			TermName = *envnew;			if (*ptr)			    if(!TEK4014_ACTIVE(screen))				resize(screen, termcap, newtc);			break;		}		envnew++;	    }	}#if OPT_INITIAL_ERASE	if (!resource.ptyInitialErase) {		char temp[1024], *p = temp;		char *s = tgetstr(TERMCAP_ERASE, &p);		TRACE(("extracting initial_erase value from termcap\n"))		if (s != 0) {			if (*s == '^') {				if (*++s == '?') {					initial_erase = 127;				} else {					initial_erase = *s & 31;				}			} else if (*s == '\\') {				char *d;				int value = strtol(s, &d, 8);				if (value > 0 && d != s)					initial_erase = value;			} else {				initial_erase = *s;			}			initial_erase &= 0xff;			TRACE(("... initial_erase:%d\n", initial_erase))		}	}	if (resource.backarrow_is_erase && initial_erase == 127) {		/* see input.c */		term->keyboard.flags &= ~MODE_DECBKM;	}#endif#if defined(TIOCSSIZE) && (defined(sun) && !defined(SVR4))	/* tell tty how big window is */	if(TEK4014_ACTIVE(screen)) {		ts.ts_lines = 38;		ts.ts_cols = 81;	} else {		ts.ts_lines = screen->max_row + 1;		ts.ts_cols = screen->max_col + 1;	}#elif defined(TIOCSWINSZ)	/* tell tty how big window is */#if OPT_TEK4014	if(TEK4014_ACTIVE(screen)) {		ws.ws_row = 38;		ws.ws_col = 81;		ws.ws_xpixel = TFullWidth(screen);		ws.ws_ypixel = TFullHeight(screen);	} else#endif	{		ws.ws_row = screen->max_row + 1;		ws.ws_col = screen->max_col + 1;		ws.ws_xpixel = FullWidth(screen);		ws.ws_ypixel = FullHeight(screen);	}#endif	/* sun vs TIOCSWINSZ */	if (!am_slave) {#ifdef USE_HANDSHAKE	    if (pipe(pc_pipe) || pipe(cp_pipe))		SysError (ERROR_FORK);#endif	    if ((screen->pid = fork ()) == -1)		SysError (ERROR_FORK);	    if (screen->pid == 0) {		/*		 * now in child process		 */		TRACE_CHILD#if defined(_POSIX_SOURCE) || defined(SVR4) || defined(__convex__) || defined(SCO325) || defined(__QNX__)		int pgrp = setsid();#else		int pgrp = getpid();#endif#if defined(UTMP) && defined(USE_SYSV_UTMP)		char* ptyname;		char* ptynameptr = 0;#endif#ifdef USE_USG_PTYS#if defined(SYSV) && defined(i386) && !defined(SVR4)                if (IsPts) {	/* SYSV386 supports both, which did we open? */#endif /* SYSV && i386 && !SVR4 */		int ptyfd;		setpgrp();		grantpt (screen->respond);		unlockpt (screen->respond);		if ((ptyfd = open (ptsname(screen->respond), O_RDWR)) < 0) {		    SysError (1);		}#ifdef I_PUSH		if (ioctl (ptyfd, I_PUSH, "ptem") < 0) {		    SysError (2);		}#if !defined(SVR4) && !(defined(SYSV) && defined(i386))		if (!getenv("CONSEM") && ioctl (ptyfd, I_PUSH, "consem") < 0) {		    SysError (3);		}#endif /* !SVR4 */		if (ioctl (ptyfd, I_PUSH, "ldterm") < 0) {		    SysError (4);		}#ifdef SVR4			/* from Sony */		if (ioctl (ptyfd, I_PUSH, "ttcompat") < 0) {		    SysError (5);		}#endif /* SVR4 */#endif		tty = ptyfd;		close (screen->respond);#ifdef TIOCSWINSZ                /* tell tty how big window is */#if OPT_TEK4014                if(TEK4014_ACTIVE(screen)) {                        ws.ws_row = 24;                        ws.ws_col = 80;                        ws.ws_xpixel = TFullWidth(screen);                        ws.ws_ypixel = TFullHeight(screen);                } else#endif		{                        ws.ws_row = screen->max_row + 1;                        ws.ws_col = screen->max_col + 1;                        ws.ws_xpixel = FullWidth(screen);                        ws.ws_ypixel = FullHeight(screen);                }#endif#if defined(SYSV) && defined(i386) && !defined(SVR4)                } else {	/* else pty, not pts */#endif /* SYSV && i386 && !SVR4 */#endif /* USE_USG_PTYS */#ifdef USE_HANDSHAKE		/* warning, goes for a long ways */		/* close parent's sides of the pipes */		close (cp_pipe[0]);		close (pc_pipe[1]);		/* Make sure that our sides of the pipes are not in the		 * 0, 1, 2 range so that we don't fight with stdin, out		 * or err.		 */		if (cp_pipe[1] <= 2) {			if ((i = fcntl(cp_pipe[1], F_DUPFD, 3)) >= 0) {				(void) close(cp_pipe[1]);				cp_pipe[1] = i;			}		}		if (pc_pipe[0] <= 2) {			if ((i = fcntl(pc_pipe[0], F_DUPFD, 3)) >= 0) {				(void) close(pc_pipe[0]);				pc_pipe[0] = i;			}		}		/* we don't need the socket, or the pty master anymore */		close (ConnectionNumber(screen->display));		close (screen->respond);		/* Now is the time to set up our process group and		 * open up the pty slave.		 */#ifdef	USE_SYSV_PGRP#if defined(CRAY) && (OSMAJORVERSION > 5)		(void) setsid();#else		(void) setpgrp();#endif#endif /* USE_SYSV_PGRP */#if defined(__QNX__) && !defined(__QNXNTO__)	qsetlogin( getlogin(), ttydev );#endif		while (1) {#if defined(TIOCNOTTY) && !((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)))			if (!no_dev_tty && (tty = open ("/dev/tty", O_RDWR)) >= 0) {				ioctl (tty, TIOCNOTTY, (char *) NULL);				close (tty);			}#endif /* TIOCNOTTY && !glibc >= 2.1 */#ifdef CSRG_BASED			(void)revoke(ttydev);#endif			if ((tty = open(ttydev, O_RDWR, 0)) >= 0) {#if defined(CRAY) && defined(TCSETCTTY)			    /* make /dev/tty work */			    ioctl(tty, TCSETCTTY, 0);#endif#ifdef	USE_SYSV_PGRP				/* We need to make sure that we are acutally				 * the process group leader for the pty.  If				 * we are, then we should now be able to open				 * /dev/tty.				 */				if ((i = open("/dev/tty", O_RDWR, 0)) >= 0) {					/* success! */					close(i);					break;				}#else	/* USE_SYSV_PGRP */				break;#endif	/* USE_SYSV_PGRP */			}#ifdef TIOCSCTTY			ioctl(tty, TIOCSCTTY, 0);#endif			/* let our master know that the open failed */			handshake.status = PTY_BAD;			handshake.error = errno;			strcpy(handshake.buffer, ttydev);			write(cp_pipe[1], (char *) &handshake,			    sizeof(handshake));			/* get reply from parent */			i = read(pc_pipe[0], (char *) &handshake,			    sizeof(handshake));			if (i <= 0) {				/* parent terminated */				exit(1);			}			if (handshake.status == PTY_NOMORE) {				/* No more ptys, let's shutdown. */				exit(1);			}			/* We have a new pty to try */			free(ttydev);			ttydev = (char *)malloc((unsigned)			    (strlen(handshake.buffer) + 1));			if (ttydev == NULL) {			    SysError(ERROR_SPREALLOC);			}			strcpy(ttydev, handshake.buffer);		}		/* use the same tty name that everyone else will use		 * (from ttyname)		 */		if ((ptr = ttyname(tty)) != 0)		{			/* it may be bigger */			ttydev = (char *)realloc (ttydev,				(unsigned) (strlen(ptr) + 1));			if (ttydev == NULL) {			    SysError(ERROR_SPREALLOC);			}			(void) strcpy(ttydev, ptr);		}#if defined(SYSV) && defined(i386) && !defined(SVR4)                } /* end of IsPts else clause */#endif /* SYSV && i386 && !SVR4 */#endif /* USE_HANDSHAKE -- from near fork */#ifdef USE_TTY_GROUP	{		struct group *ttygrp;		if ((ttygrp = getgrnam("tty")) != 0) {			/* change ownership of tty to real uid, "tty" gid */			set_owner (ttydev, screen->uid, ttygrp->gr_gid, 0620);		}		else {			/* change ownership of tty to real group and user id */			set_owner (ttydev, screen->uid, screen->gid, 0622);		}		endgrent();	}#else /* else !USE_TTY_GROUP */		/* change ownership of tty to real group and user id */		set_owner (ttydev, screen->uid, screen->gid, 0622);#endif /* USE_TTY_GROUP */		/*		 * set up the tty modes		 */		{#if defined(USE_SYSV_TERMIO) || defined(USE_POSIX_TERMIOS)#if defined(umips) || defined(CRAY) || defined(linux)		    /* If the control tty had its modes screwed around with,		       eg. by lineedit in the shell, or emacs, etc. then tio		       will have bad values.  Let's just get termio from the		       new tty and tailor it.  */		    if (ioctl (tty, TCGETA, &tio) == -1)		      SysError (ERROR_TIOCGETP);		    tio.c_lflag |= ECHOE;#endif /* umips */		    /* Now is also the time to change the modes of the		     * child pty.		     */		    /* input: nl->nl, don't ignore cr, cr->nl */		    tio.c_iflag &= ~(INLCR|IGNCR);		    tio.c_iflag |= ICRNL;		    /* ouput: cr->cr, nl is not return, no delays, ln->cr/nl */#ifndef USE_POSIX_TERMIOS		    tio.c_oflag &=		     ~(OCRNL|ONLRET|NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY);#endif /* USE_POSIX_TERMIOS */#ifdef ONLCR		    tio.c_oflag |= ONLCR;#endif /* ONLCR */		    #ifdef OPOST		    tio.c_oflag |= OPOST;#endif /* OPOST */#ifdef MINIX	/* should be ifdef _POSIX_SOURCE */		    cfsetispeed(&tio, B9600);		    cfsetospeed(&tio, B9600);#else /* !MINIX */#ifndef USE_POSIX_TERMIOS#ifdef BAUD_0		    /* baud rate is 0 (don't care) */		    tio.c_cflag &= ~(CBAUD);#else	/* !BAUD_0 */		    /* baud rate is 9600 (nice default) */		    tio.c_cflag &= ~(CBAUD);		    tio.c_cflag |= B9600;#endif	/* !BAUD_0 */#else /* USE_POSIX_TERMIOS */		    cfsetispeed(&tio, B9600);		    cfsetospeed(&tio, B9600);		    /* Clear CLOCAL so that SIGHUP is sent to us		       when the xterm ends */		    tio.c_cflag &= ~CLOCAL;#endif /* USE_POSIX_TERMIOS */#endif /* MINIX */		    tio.c_cflag &= ~CSIZE;		    if (screen->input_eight_bits)			tio.c_cflag |= CS8;		    else			tio.c_cflag |= CS7;		    /* enable signals, canonical processing (erase, kill, etc),		    ** echo		    */		    tio.c_lflag |= ISIG|ICANON|ECHO|ECHOE|ECHOK;#ifdef ECHOKE		    tio.c_lflag |= ECHOKE|IEXTEN;#endif#ifdef ECHOCTL		    tio.c_lflag |= ECHOCTL|IEXTEN;#endif		    /* reset EOL to default value */		    tio.c_cc[VEOL] = CEOL;			/* '^@' */		    /* certain shells (ksh & csh) change EOF as well */		    tio.c_cc[VEOF] = CEOF;			/* '^D' */#ifdef VLNEXT		    tio.c_cc[VLNEXT] = CLNEXT;#endif#ifdef VWERASE		    tio.c_cc[VWERASE] = CWERASE;#endif#ifdef VREPRINT		    tio.c_cc[VREPRINT] = CRPRNT;#endif#ifdef VRPRNT		    tio.c_cc[VRPRNT] = CRPRNT;#endif#ifdef VDISCARD		    tio.c_cc[VDISCARD] = CFLUSH;#endif#ifdef VFLUSHO		    tio.c_cc[VFLUSHO] = CFLUSH;#endif#ifdef VSTOP		    tio.c_cc[VSTOP] = CSTOP;#endif#ifdef VSTART		    tio.c_cc[VSTART] = CSTART;#endif#ifdef VSUSP		    tio.c_cc[VSUSP] = CSUSP;#endif#ifdef VDSUSP		    tio.c_cc[VDSUSP] = CDSUSP;#endif		    if (override_tty_modes) {			/* sysv-specific */			TMODE (XTTYMODE_intr, tio.c_cc[VINTR]);			TMODE (XTTYMODE_quit, tio.c_cc[VQUIT]);			TMODE (XTTYMODE_erase, tio.c_cc[VERASE]);			TMODE (XTTYMODE_kill, tio.c_cc[VKILL]);			TMODE (XTTYMODE_eof, tio.c_cc[VEOF]);			TMODE (XTTYMODE_eol, tio.c_cc[VEOL]);#ifdef VSWTCH			TMODE (XTTYMODE_swtch, tio.c_cc[VSWTCH]);#endif#ifdef VSUSP			TMODE (XTTYMODE_susp, tio.c_cc[VSUSP]);#endif#ifdef VDSUSP			TMODE (XTTYMODE_dsusp, tio.c_cc[VDSUSP]);#endif#ifdef VREPRINT			TMODE (XTTYMODE_rprnt, tio.c_cc[VREPRINT]);#endif#ifdef VRPRNT			TMODE (XTTYMODE_rprnt, tio.c_cc[VRPRNT]);#endif#ifdef VDISCARD			TMODE (XTTYMODE_flush, tio.c_cc[VDISCARD]);#endif#ifdef VFLUSHO			TMODE (XTTYMODE_flush, tio.c_cc[VFLUSHO]);#endif#ifdef VWERASE			TMODE (XTTYMODE_weras, tio.c_cc[VWERASE]);#endif#ifdef VLNEXT			TMODE (XTTYMODE_lnext, tio.c_cc[VLNEXT]);#endif#ifdef VSTART			TMODE (XTTYMODE_start, tio.c_cc[VSTART]);#endif#ifdef VSTOP			TMODE (XTTYMODE_stop, tio.c_cc[VSTOP]);#endif#ifdef VSTATUS			TMODE (XTTYMODE_status, tio.c_cc[VSTATUS]);#endif#ifdef HAS_LTCHARS			/* both SYSV and BSD have ltchars */			TMODE (XTTYMODE_susp, ltc.t_suspc);			TMODE (XTTYMODE_dsusp, ltc.t_dsuspc);			TMODE (XTTYMODE_rprnt, ltc.t_rprntc);			TMODE (XTTYMODE_flush, ltc.t_flushc);			TMODE (XTTYMODE_weras, ltc.t_werasc);			TMODE (XTTYMODE_lnext, ltc.t_lnextc);#endif		    }#ifdef HAS_LTCHARS#ifdef __hpux		    /* ioctl chokes when the "reserved" process group controls		     * are not set to _POSIX_VDISABLE */		    ltc.t_rprntc = ltc.t_rprntc = ltc.t_flushc =		    ltc.t_werasc = ltc.t_lnextc = _POSIX_VDISABLE;#endif /* __hpux */		    if (ioctl (tty, TIOCSLTC, &ltc) == -1)			    HsSysError(cp_pipe[1], ERROR_TIOCSETC);#endif	/* HAS_LTCHARS */#ifdef TIOCLSET		    if (ioctl (tty, TIOCLSET, (char *)&lmode) == -1)			    HsSysError(cp_pipe[1], ERROR_TIOCLSET);#endif	/* TIOCLSET */#ifndef USE_POSIX_TERMIOS		    if (ioctl (tty, TCSETA, &tio) == -1)			    HsSysError(cp_pipe[1], ERROR_TIOCSETP);#else   /* USE_POSIX_TERMIOS */		    if (tcsetattr (tty, TCSANOW, &tio) == -1)			    HsSysError(cp_pipe[1], ERROR_TIOCSETP);#endif  /* USE_POSIX_TERMIOS */#else	/* USE_SYSV_TERMIO or USE_POSIX_TERMIOS */		    sg.sg_flags &= ~(ALLDELAY | XTABS | CBREAK | RAW);		    sg.sg_flags |= ECHO | CRMOD;		    /* make sure speed is set on pty so that editors work right*/		    sg.sg_ispeed = B9600;		    sg.sg_ospeed = B9600;		    /* reset t_brkc to default value */		    tc.t_brkc = -1;#ifdef LPASS8		    if (screen->input_eight_bits)			lmode |= LPASS8;		    else			lmode &= ~(LPASS8);#endif#ifdef sony		    jmode &= ~KM_KANJI;#endif /* sony */		    ltc = d_ltc;		    if (override_tty_modes) {			TMODE (XTTYMODE_intr, tc.t_intrc);			TMODE (XTTYMODE_quit, tc.t_quitc);			TMODE (XTTYMODE_erase, sg.sg_erase);			TMODE (XTTYMODE_kill, sg.sg_kill);			TMODE (XTTYMODE_eof, tc.t_eofc);			TMODE (XTTYMODE_start, tc.t_startc);			TMODE (XTTYMODE_stop, tc.t_stopc);			TMODE (XTTYMODE_brk, tc.t_brkc);			/* both SYSV and BSD have ltchars */			TMODE (XTTYMODE_susp, ltc.t_suspc);			TMODE (XTTYMODE_dsusp, ltc.t_dsuspc);			TMODE (XTTYMODE_rprnt, ltc.t_rprntc);			TMODE (XTTYMODE_flush, ltc.t_flushc);			TMODE (XTTYMODE_weras, ltc.t_werasc);			TMODE (XTTYMODE_lnext, ltc.t_lnextc);		    }		    if (ioctl (tty, TIOCSETP, (char *)&sg) == -1)			    HsSysError (cp_pipe[1], ERROR_TIOCSETP);		    if (ioctl (tty, TIOCSETC, (char *)&tc) == -1)			    HsSysError (cp_pipe[1], ERROR_TIOCSETC);		    if (ioctl (tty, TIOCSETD, (char *)&discipline) == -1)			    HsSysError (cp_pipe[1], ERROR_TIOCSETD);		    if (ioctl (tty, TIOCSLTC, (char *)&ltc) == -1)			    HsSysError (cp_pipe[1], ERROR_TIOCSLTC);		    if (ioctl (tty, TIOCLSET, (char *)&lmode) == -1)			    HsSysError (cp_pipe[1], ERROR_TIOCLSET);#ifdef sony		    if (ioctl (tty, TIOCKSET, (char *)&jmode) == -1)			    HsSysError (cp_pipe[1], ERROR_TIOCKSET);		    if (ioctl (tty, TIOCKSETC, (char *)&jtc) == -1)			    HsSysError (cp_pipe[1], ERROR_TIOCKSETC);#endif /* sony */#endif	/* !USE_SYSV_TERMIO */#if defined(TIOCCONS) || defined(SRIOCSREDIR)		    if (Console) {#ifdef TIOCCONS			int on = 1;			if (ioctl (tty, TIOCCONS, (char *)&on) == -1)			    fprintf(stderr, "%s: cannot open console\n",				    xterm_name);#endif#ifdef SRIOCSREDIR			int fd = open("/dev/console",O_RDWR);			if (fd == -1 || ioctl (fd, SRIOCSREDIR, tty) == -1)			    fprintf(stderr, "%s: cannot open console\n",				    xterm_name);			(void) close (fd);#endif		    }#endif	/* TIOCCONS */		}		signal (SIGCHLD, SIG_DFL);#ifdef USE_SYSV_SIGHUP		/* watch out for extra shells (I don't understand either) */		signal (SIGHUP, SIG_DFL);#else		signal (SIGHUP, SIG_IGN);#endif		/* restore various signals to their defaults */		signal (SIGINT, SIG_DFL);		signal (SIGQUIT, SIG_DFL);		signal (SIGTERM, SIG_DFL);#if OPT_INITIAL_ERASE		if (! resource.ptyInitialErase		 && !override_tty_modes		 && !ttymodelist[XTTYMODE_erase].set) {#ifdef USE_SYSV_TERMIO			if(ioctl(tty, TCGETA, &tio) == -1)				tio = d_tio;			tio.c_cc[VERASE] = initial_erase;			ioctl(tty, TCSETA, &tio);#elif defined(USE_POSIX_TERMIOS)			if (tcgetattr(tty, &tio) == -1)				tio = d_tio;			tio.c_cc[VERASE] = initial_erase;			tcsetattr(tty, TCSANOW, &tio);#else   /* !USE_SYSV_TERMIO && !USE_POSIX_TERMIOS */			if(ioctl(tty, TIOCGETP, (char *)&sg) == -1)				sg = d_sg;			sg.sg_erase = initial_erase;			ioctl(tty, TIOCSETP, (char *)&sg);#endif	/* USE_SYSV_TERMIO */		}#endif		/* copy the environment before Setenving */		for (i = 0 ; environ [i] != NULL ; i++)		    ;		/* compute number of Setenv() calls below */		envsize = 1;	/* (NULL terminating entry) */		envsize += 3;	/* TERM, WINDOWID, DISPLAY */#ifdef UTMP		envsize += 1;   /* LOGNAME */#endif /* UTMP */#ifdef USE_SYSV_ENVVARS		envsize += 2;	/* COLUMNS, LINES */#ifdef UTMP		envsize += 2;   /* HOME, SHELL */#endif /* UTMP */#ifdef OWN_TERMINFO_DIR		envsize += 1;	/* TERMINFO */#endif#else /* USE_SYSV_ENVVARS */		envsize += 1;	/* TERMCAP */#endif /* USE_SYSV_ENVVARS */		envnew = (char **) calloc ((unsigned) i + envsize, sizeof(char *));		memmove( (char *)envnew, (char *)environ, i * sizeof(char *));		environ = envnew;		Setenv ("TERM=", TermName);		if(!TermName)			*newtc = 0;		sprintf (buf, "%lu",			 ((unsigned long) XtWindow (XtParent(CURRENT_EMU(screen)))));		Setenv ("WINDOWID=", buf);		/* put the display into the environment of the shell*/		Setenv ("DISPLAY=", XDisplayString (screen->display));		signal(SIGTERM, SIG_DFL);#ifndef AMOEBA		/* this is the time to go and set up stdin, out, and err		 */		{#if defined(CRAY) && (OSMAJORVERSION >= 6)		    (void) close(tty);		    (void) close(0);		    if (open ("/dev/tty", O_RDWR)) {			fprintf(stderr, "cannot open /dev/tty\n");			exit(1);		    }		    (void) close(1);		    (void) close(2);		    dup(0);		    dup(0);#else		    /* dup the tty */		    for (i = 0; i <= 2; i++)			if (i != tty) {			    (void) close(i);			    (void) dup(tty);			}#ifndef ATT		    /* and close the tty */		    if (tty > 2)			(void) close(tty);#endif#endif /* CRAY */		}#ifndef	USE_SYSV_PGRP#ifdef TIOCSCTTY		setsid();		ioctl(0, TIOCSCTTY, 0);#endif		ioctl(0, TIOCSPGRP, (char *)&pgrp);#ifndef __osf__		setpgrp(0,0);#else		setpgid(0,0);#endif		close(open(ttydev, O_WRONLY, 0));#ifndef __osf__		setpgrp (0, pgrp);#else		setpgid (0, pgrp);#endif#endif /* !USE_SYSV_PGRP */#if defined(__QNX__)    tcsetpgrp( 0, pgrp /*setsid()*/ );#endif#endif /* AMOEBA */#ifdef Lynx	{	struct termio	t;	if (ioctl(0, TCGETA, &t) >= 0)	{		/* this gets lost somewhere on our way... */		t.c_oflag |= OPOST;		ioctl(0, TCSETA, &t);	}	}#endif#ifdef UTMP		pw = getpwuid(screen->uid);		if (pw && pw->pw_name)		    Setenv ("LOGNAME=", pw->pw_name); /* for POSIX */#ifdef USE_SYSV_UTMP		/* Set up our utmp entry now.  We need to do it here		** for the following reasons:		**   - It needs to have our correct process id (for		**     login).		**   - If our parent was to set it after the fork(),		**     it might make it out before we need it.		**   - We need to do it before we go and change our		**     user and group id's.		*/#ifdef CRAY#define PTYCHARLEN 4#endif#ifdef __osf__#define PTYCHARLEN 5#endif#ifndef PTYCHARLEN#define PTYCHARLEN 2#endif		(void) setutent ();		/* set up entry to search for */		ptyname = ttydev;		bzero(&utmp, sizeof(utmp));#ifndef __sgi		if (PTYCHARLEN >= (int)strlen(ptyname))		    ptynameptr = ptyname;		else		    ptynameptr = ptyname + strlen(ptyname) - PTYCHARLEN;#else		ptynameptr = ptyname + sizeof("/dev/tty")-1;#endif		(void) strncpy(utmp.ut_id, ptynameptr, sizeof (utmp.ut_id));		utmp.ut_type = DEAD_PROCESS;		/* position to entry in utmp file */		(void) getutid(&utmp);		/* set up the new entry */		utmp.ut_type = USER_PROCESS;#if !(defined(linux) && (!defined(__GLIBC__) || (__GLIBC__ < 2))) && !defined(SVR4)		utmp.ut_exit.e_exit = 2;#endif		(void) strncpy(utmp.ut_user,			       (pw && pw->pw_name) ? pw->pw_name : "????",			       sizeof(utmp.ut_user));		/* why are we copying this string again? look up 16 lines. */		(void)strncpy(utmp.ut_id, ptynameptr, sizeof(utmp.ut_id));		(void) strncpy (utmp.ut_line,			ptyname + strlen("/dev/"), sizeof (utmp.ut_line));#ifdef HAS_UTMP_UT_HOST		(void) strncpy(buf, DisplayString(screen->display),			       sizeof(buf));#ifndef linux	        {		    char *disfin = strrchr(buf, ':');		    if (disfin)			*disfin = '\0';		}#endif		(void) strncpy(utmp.ut_host, buf, sizeof(utmp.ut_host));#endif		(void) strncpy(utmp.ut_name, pw->pw_name,			       sizeof(utmp.ut_name));		utmp.ut_pid = getpid();#if defined(SVR4) || defined(SCO325) || (defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && !(defined(__powerpc__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)))		utmp.ut_session = getsid(0);		utmp.ut_xtime = time ((time_t *) 0);		utmp.ut_tv.tv_usec = 0;#else		utmp.ut_time = time ((time_t *) 0);#endif		/* write out the entry */		if (!resource.utmpInhibit)		    (void) pututline(&utmp);#ifdef WTMP#if defined(SVR4) || defined(SCO325)		if (term->misc.login_shell)		    updwtmpx(WTMPX_FILE, &utmp);#elif defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && !(defined(__powerpc__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0))		if (term->misc.login_shell)		    updwtmp(etc_wtmp, &utmp);#else		if (term->misc.login_shell &&		     (i = open(etc_wtmp, O_WRONLY|O_APPEND)) >= 0) {		    write(i, (char *)&utmp, sizeof(struct utmp));		    close(i);		}#endif#endif		/* close the file */		(void) endutent();#else	/* USE_SYSV_UTMP */		/* We can now get our ttyslot!  We can also set the initial		 * UTMP entry.		 */		tslot = ttyslot();		added_utmp_entry = False;		{			if (pw && !resource.utmpInhibit &&			    (i = open(etc_utmp, O_WRONLY)) >= 0) {				bzero((char *)&utmp, sizeof(struct utmp));				(void) strncpy(utmp.ut_line,					       ttydev + strlen("/dev/"),					       sizeof(utmp.ut_line));				(void) strncpy(utmp.ut_name, pw->pw_name,					       sizeof(utmp.ut_name));#ifdef MINIX				utmp.ut_pid = getpid();				utmp.ut_type = USER_PROCESS;#endif /* MINIX */#ifdef HAS_UTMP_UT_HOST				(void) strncpy(utmp.ut_host,					       XDisplayString (screen->display),					       sizeof(utmp.ut_host));#endif				/* cast needed on Ultrix 4.4 */				time((time_t*)&utmp.ut_time);				lseek(i, (long)(tslot * sizeof(struct utmp)), 0);				write(i, (char *)&utmp, sizeof(struct utmp));				close(i);				added_utmp_entry = True;#if defined(WTMP)				if (term->misc.login_shell &&				(i = open(etc_wtmp, O_WRONLY|O_APPEND)) >= 0) {				    int status;				    status = write(i, (char *)&utmp,						   sizeof(struct utmp));				    status = close(i);				}#elif defined(MNX_LASTLOG)				if (term->misc.login_shell &&				(i = open(_U_LASTLOG, O_WRONLY)) >= 0) {				    lseek(i, (long)(screen->uid *					sizeof (struct utmp)), 0);				    write(i, (char *)&utmp,					sizeof (struct utmp));				    close(i);				}#endif /* WTMP or MNX_LASTLOG */			} else				tslot = -tslot;		}		/* Let's pass our ttyslot to our parent so that it can		 * clean up after us.		 */#ifdef USE_HANDSHAKE		handshake.tty_slot = tslot;#endif /* USE_HANDSHAKE */#endif /* USE_SYSV_UTMP */#ifdef LASTLOG				if (term->misc.login_shell &&				(i = open(etc_lastlog, O_WRONLY)) >= 0) {				    bzero((char *)&lastlog,					sizeof (struct lastlog));				    (void) strncpy(lastlog.ll_line, ttydev +					sizeof("/dev"),					sizeof (lastlog.ll_line));				    (void) strncpy(lastlog.ll_host,					  XDisplayString (screen->display),					  sizeof (lastlog.ll_host));				    time(&lastlog.ll_time);				    lseek(i, (long)(screen->uid *					sizeof (struct lastlog)), 0);				    write(i, (char *)&lastlog,					sizeof (struct lastlog));				    close(i);				}#endif /* LASTLOG */#ifdef USE_HANDSHAKE		/* Let our parent know that we set up our utmp entry		 * so that it can clean up after us.		 */		handshake.status = UTMP_ADDED;		handshake.error = 0;		strcpy(handshake.buffer, ttydev);		(void)write(cp_pipe[1], (char *)&handshake, sizeof(handshake));#endif /* USE_HANDSHAKE */#endif/* UTMP */		(void) setgid (screen->gid);#ifdef HAS_BSD_GROUPS		if (geteuid() == 0 && pw)		  initgroups (pw->pw_name, pw->pw_gid);#endif		(void) setuid (screen->uid);#ifdef USE_HANDSHAKE		/* mark the pipes as close on exec */		fcntl(cp_pipe[1], F_SETFD, 1);		fcntl(pc_pipe[0], F_SETFD, 1);		/* We are at the point where we are going to		 * exec our shell (or whatever).  Let our parent		 * know we arrived safely.		 */		handshake.status = PTY_GOOD;		handshake.error = 0;		(void)strcpy(handshake.buffer, ttydev);		(void)write(cp_pipe[1], (char *)&handshake, sizeof(handshake));		if (waiting_for_initial_map) {		    i = read (pc_pipe[0], (char *) &handshake,			      sizeof(handshake));		    if (i != sizeof(handshake) ||			handshake.status != PTY_EXEC) {			/* some very bad problem occurred */			exit (ERROR_PTY_EXEC);		    }		    if(handshake.rows > 0 && handshake.cols > 0) {			screen->max_row = handshake.rows;			screen->max_col = handshake.cols;#if defined(TIOCSSIZE) && (defined(sun) && !defined(SVR4))			ts.ts_lines = screen->max_row + 1;			ts.ts_cols = screen->max_col + 1;#elif defined(TIOCSWINSZ)			ws.ws_row = screen->max_row + 1;			ws.ws_col = screen->max_col + 1;			ws.ws_xpixel = FullWidth(screen);			ws.ws_ypixel = FullHeight(screen);#endif /* sun vs TIOCSWINSZ */		    }		}#endif /* USE_HANDSHAKE */#ifdef USE_SYSV_ENVVARS		{		char numbuf[12];		sprintf (numbuf, "%d", screen->max_col + 1);		Setenv("COLUMNS=", numbuf);		sprintf (numbuf, "%d", screen->max_row + 1);		Setenv("LINES=", numbuf);		}#ifdef UTMP		if (pw) {	/* SVR4 doesn't provide these */		    if (!getenv("HOME"))			Setenv("HOME=", pw->pw_dir);		    if (!getenv("SHELL"))			Setenv("SHELL=", pw->pw_shell);		}#endif /* UTMP */#ifdef OWN_TERMINFO_DIR		Setenv("TERMINFO=", OWN_TERMINFO_DIR);#endif#else /* USE_SYSV_ENVVARS */		if(!TEK4014_ACTIVE(screen) && *newtc) {		    strcpy (termcap, newtc);		    resize (screen, termcap, newtc);		}		if (term->misc.titeInhibit) {		    remove_termcap_entry (newtc, "ti=");		    remove_termcap_entry (newtc, "te=");		}		/*		 * work around broken termcap entries */		if (resource.useInsertMode)	{		    remove_termcap_entry (newtc, "ic=");		    /* don't get duplicates */		    remove_termcap_entry (newtc, "im=");		    remove_termcap_entry (newtc, "ei=");		    remove_termcap_entry (newtc, "mi");		    if(*newtc)			strcat (newtc, ":im=\\E[4h:ei=\\E[4l:mi:");		}#if OPT_INITIAL_ERASE		if (*newtc) {		    remove_termcap_entry (newtc, TERMCAP_ERASE "=");		    sprintf(newtc + strlen(newtc), ":%s=\\%03o", TERMCAP_ERASE, initial_erase & 0377);		}#endif		if(*newtc)		    Setenv ("TERMCAP=", newtc);#endif /* USE_SYSV_ENVVARS */		/* need to reset after all the ioctl bashing we did above */#if defined(TIOCSSIZE) && (defined(sun) && !defined(SVR4))		i = ioctl (0, TIOCSSIZE, &ts);		TRACE(("spawn TIOCSSIZE %dx%d return %d\n", ts.ts_lines, ts.ts_cols, i))#elif defined(TIOCSWINSZ)		i = ioctl (0, TIOCSWINSZ, (char *)&ws);		TRACE(("spawn TIOCSWINSZ %dx%d return %d\n", ws.ws_row, ws.ws_col, i))#else		TRACE(("spawn cannot tell pty its size\n"))#endif	/* sun vs TIOCSWINSZ */		signal(SIGHUP, SIG_DFL);		if (command_to_exec) {			execvp(*command_to_exec, command_to_exec);			/* print error message on screen */			fprintf(stderr, "%s: Can't execvp %s\n", xterm_name,			 *command_to_exec);		}#ifdef USE_SYSV_SIGHUP		/* fix pts sh hanging around */		signal (SIGHUP, SIG_DFL);#endif#ifdef UTMP		if(((ptr = getenv("SHELL")) == NULL || *ptr == 0) &&		 ((pw == NULL && (pw = getpwuid(screen->uid)) == NULL) ||		 *(ptr = pw->pw_shell) == 0))#else	/* UTMP */		if(((ptr = getenv("SHELL")) == NULL || *ptr == 0) &&		 ((pw = getpwuid(screen->uid)) == NULL ||		 *(ptr = pw->pw_shell) == 0))#endif	/* UTMP */			ptr = "/bin/sh";		if ((shname = strrchr(ptr, '/')) != 0)			shname++;		else			shname = ptr;		shname_minus = (char *)malloc(strlen(shname) + 2);		(void) strcpy(shname_minus, "-");		(void) strcat(shname_minus, shname);#if !defined(USE_SYSV_TERMIO) && !defined(USE_POSIX_TERMIOS)		ldisc = XStrCmp("csh", shname + strlen(shname) - 3) == 0 ?		 NTTYDISC : 0;		ioctl(0, TIOCSETD, (char *)&ldisc);#endif	/* !USE_SYSV_TERMIO && !USE_POSIX_TERMIOS */#ifdef USE_LOGIN_DASH_P		if (term->misc.login_shell && pw && added_utmp_entry)		  execl (bin_login, "login", "-p", "-f", pw->pw_name, 0);#endif		execlp (ptr, (term->misc.login_shell ? shname_minus : shname),			0);		/* Exec failed. */		fprintf (stderr, "%s: Could not exec %s!\n", xterm_name, ptr);		(void) sleep(5);		exit(ERROR_EXEC);	    }				/* end if in child after fork */#ifdef USE_HANDSHAKE	    /* Parent process.  Let's handle handshaked requests to our	     * child process.	     */	    /* close childs's sides of the pipes */	    close (cp_pipe[1]);	    close (pc_pipe[0]);	    for (done = 0; !done; ) {		if (read(cp_pipe[0], (char *) &handshake, sizeof(handshake)) <= 0) {			/* Our child is done talking to us.  If it terminated			 * due to an error, we will catch the death of child			 * and clean up.			 */			break;		}		switch(handshake.status) {		case PTY_GOOD:			/* Success!  Let's free up resources and			 * continue.			 */			done = 1;			break;		case PTY_BAD:			/* The open of the pty failed!  Let's get			 * another one.			 */			(void) close(screen->respond);			if (get_pty(&screen->respond)) {			    /* no more ptys! */			    (void) fprintf(stderr,			      "%s: child process can find no available ptys\n",			      xterm_name);			    handshake.status = PTY_NOMORE;			    write(pc_pipe[1], (char *) &handshake, sizeof(handshake));			    exit (ERROR_PTYS);			}			handshake.status = PTY_NEW;			(void) strcpy(handshake.buffer, ttydev);			write(pc_pipe[1], (char *) &handshake, sizeof(handshake));			break;		case PTY_FATALERROR:			errno = handshake.error;			close(cp_pipe[0]);			close(pc_pipe[1]);			SysError(handshake.fatal_error);		case UTMP_ADDED:			/* The utmp entry was set by our slave.  Remember			 * this so that we can reset it later.			 */			added_utmp_entry = True;#ifndef	USE_SYSV_UTMP			tslot = handshake.tty_slot;#endif	/* USE_SYSV_UTMP */			free(ttydev);			ttydev = (char *)malloc((unsigned) strlen(handshake.buffer) + 1);			strcpy(ttydev, handshake.buffer);			break;		default:			fprintf(stderr, "%s: unexpected handshake status %d\n",			        xterm_name, handshake.status);		}	    }	    /* close our sides of the pipes */	    if (!waiting_for_initial_map) {		close (cp_pipe[0]);		close (pc_pipe[1]);	    }#endif /* USE_HANDSHAKE */	}				/* end if no slave */	/*	 * still in parent (xterm process)	 */#ifdef USE_SYSV_SIGHUP	/* hung sh problem? */	signal (SIGHUP, SIG_DFL);#else	signal (SIGHUP, SIG_IGN);#endif/* * Unfortunately, System V seems to have trouble divorcing the child process * from the process group of xterm.  This is a problem because hitting the * INTR or QUIT characters on the keyboard will cause xterm to go away if we * don't ignore the signals.  This is annoying. */#if defined(USE_SYSV_SIGNALS) && !defined(SIGTSTP)	signal (SIGINT, SIG_IGN);#ifndef SYSV	/* hung shell problem */	signal (SIGQUIT, SIG_IGN);#endif	signal (SIGTERM, SIG_IGN);#elif defined(SYSV) || defined(__osf__)	/* if we were spawned by a jobcontrol smart shell (like ksh or csh),	 * then our pgrp and pid will be the same.  If we were spawned by	 * a jobcontrol dumb shell (like /bin/sh), then we will be in our	 * parent's pgrp, and we must ignore keyboard signals, or we will	 * tank on everything.	 */	if (getpid() == getpgrp()) {	    (void) signal(SIGINT, Exit);	    (void) signal(SIGQUIT, Exit);	    (void) signal(SIGTERM, Exit);	} else {	    (void) signal(SIGINT, SIG_IGN);	    (void) signal(SIGQUIT, SIG_IGN);	    (void) signal(SIGTERM, SIG_IGN);	}	(void) signal(SIGPIPE, Exit);#else	/* SYSV */	signal (SIGINT, Exit);	signal (SIGQUIT, Exit);	signal (SIGTERM, Exit);        signal (SIGPIPE, Exit);#endif /* USE_SYSV_SIGNALS and not SIGTSTP */	return 0;}							/* end spawn */