datri@convex.com (Anthony A. Datri) (08/27/90)
I've been trying to build a usable tcsh for our 9000/3xx's under 7.0 with only limited success -- 5.18+4.3csh will build, but jobs have a way of getting stopped. Any advice? -- beak is beak is not
mark@comp.vuw.ac.nz (Mark Davies) (08/29/90)
In article <105389@convex.convex.com> datri@convex.com (Anthony A. Datri) writes: >I've been trying to build a usable tcsh for our 9000/3xx's under 7.0 with >only limited success -- 5.18+4.3csh will build, but jobs have a way >of getting stopped. Any advice? Yes Reverse the order it does the setpgrp and the TIOCSPGRP ioctl in sh.proc.c. Also define VFORK in config.h as hp-ux has one. Here are the patches to 5.18 I made to get it to run on various systems including 9000/3xx's and 9000/8xx's under hp-ux 7.0. These patches don't completely fix the problem of jobs getting stopped but certainly make tcsh useable under 7.0. cheers mark *** sh.c.orig Thu Mar 29 11:13:53 1990 --- sh.c Fri Mar 30 13:43:18 1990 *************** *** 83,89 **** bool periodic_active = 0; bool cwdcmd_active = 0; /* PWP: for cwd_cmd */ char buff[128]; /* for gethostname(2), and printprompt() */ - bool bslash_quote = 0; /* PWP: do tcsh-style backslash quoting? */ #define DEFAULT_AUTOLOGOUT "60" /* 1 Hour Alarm default */ --- 83,88 ---- *************** *** 157,162 **** --- 156,162 ---- HIST = '!'; HISTSUB = '^'; word_chars = WORD_CHARS; + bslash_quote = 0; /* PWP: do tcsh-style backslash quoting? */ v = av; if (eq(v[0], "a.out")) /* A.out's are quittable */ *************** *** 438,443 **** --- 438,453 ---- setenv ("HOSTTYPE", "gould"); #endif /* GOULD_PN */ + #ifdef hp9000 + /* hp9000 running MORE/bsd */ + #ifdef hp300 + setenv("HOSTTYPE", "hp300"); + #endif + #ifdef hp800 + setenv("HOSTTYPE", "hp800"); + #endif + #endif /* hp9000 */ + /* * set editing on by default, unless running under Emacs as * an inferior shell. *************** *** 701,708 **** f = -1; retry: #ifdef BSDJOBS /* if we have tty job control */ ! if (ioctl(f, TIOCGPGRP, (char *)&tpgrp) == 0 && ! tpgrp != -1) { int ldisc; if (tpgrp != shpgrp) { SIGRETTYPE (*old)() = --- 711,717 ---- f = -1; retry: #ifdef BSDJOBS /* if we have tty job control */ ! if ((tpgrp = tcgetpgrp(f)) != -1) { int ldisc; if (tpgrp != shpgrp) { SIGRETTYPE (*old)() = *************** *** 760,767 **** opgrp = shpgrp; shpgrp = getpid(); tpgrp = shpgrp; ! (void) ioctl(f, TIOCSPGRP, &shpgrp); ! (void) setpgrp(0, shpgrp); # ifdef FIOCLEX (void) ioctl(dcopy(f, FSHTTY), FIOCLEX, (char *)0); --- 769,776 ---- opgrp = shpgrp; shpgrp = getpid(); tpgrp = shpgrp; ! (void) tcsetpgrp(f, shpgrp); ! (void) setpgid(0, shpgrp); # ifdef FIOCLEX (void) ioctl(dcopy(f, FSHTTY), FIOCLEX, (char *)0); *************** *** 865,872 **** { #ifdef BSDJOBS if (tpgrp > 0) { ! (void) setpgrp(0, opgrp); ! (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&opgrp); # ifndef OREO # ifndef hpux # ifndef IRIS4D --- 874,881 ---- { #ifdef BSDJOBS if (tpgrp > 0) { ! (void) setpgid(0, opgrp); ! (void) tcsetpgrp(FSHTTY, opgrp); # ifndef OREO # ifndef hpux # ifndef IRIS4D *************** *** 1803,1809 **** */ while (read (utmpfd, &utmp, sizeof utmp) == sizeof utmp) { #ifdef SYSV2 ! if ( utmp.ut_type == USER_PROCESS ) { #endif /* SYSV2 */ #ifdef IRIS4D if ( utmp.ut_type == USER_PROCESS ) { --- 1812,1818 ---- */ while (read (utmpfd, &utmp, sizeof utmp) == sizeof utmp) { #ifdef SYSV2 ! if ( utmp.ut_type == USER_PROCESS || utmp.ut_type == DEAD_PROCESS) { #endif /* SYSV2 */ #ifdef IRIS4D if ( utmp.ut_type == USER_PROCESS ) { *************** *** 1810,1815 **** --- 1819,1828 ---- #endif /* IRIS4D */ if (utmp.ut_name[0] == '\0' && utmp.ut_line[0] == '\0') continue; /* completely void entry */ + #ifdef SYSV2 + if (utmp.ut_type == DEAD_PROCESS && utmp.ut_line[0] == '\0') + continue; + #endif /* SYSV2 */ wp = wholist; while ((comparison = strncmp (wp->w_tty, utmp.ut_line, UTLINLEN)) < 0) *************** *** 1816,1821 **** --- 1829,1839 ---- wp = wp->w_next; /* find that tty! */ if (comparison == 0) { /* found the tty... */ + #ifdef SYSV2 + if (utmp.ut_type == DEAD_PROCESS) + wp->w_status = OFFLINE; + else + #endif /* SYSV2 */ if (utmp.ut_name[0] == '\0') wp->w_status = OFFLINE; else /* someone is logged in */ *************** *** 1833,1838 **** --- 1851,1861 ---- } else { /* new tty in utmp */ wpnew = (struct who *) calloc (1, sizeof *wpnew); strncpy (wpnew->w_tty, utmp.ut_line, UTLINLEN); + #ifdef SYSV2 + if (utmp.ut_type == DEAD_PROCESS) + wpnew->w_status = OFFLINE; + else + #endif /* SYSV2 */ if (utmp.ut_name[0] == '\0') wpnew->w_status = OFFLINE; else { *************** *** 2417,2419 **** --- 2440,2457 ---- } #endif /* YPBUGS */ + + #if defined(BSDJOBS) && !defined(POSIXJOBS) + + tcgetpgrp (fd) + int fd; + { + int pgrp; + + /* ioctl will handle setting errno correctly. */ + if (ioctl (fd, TIOCGPGRP, &pgrp) < 0) + return (-1); + return (pgrp); + } + + #endif *** sh.err.c.orig Thu Mar 29 11:14:00 1990 --- sh.err.c Fri Mar 30 13:51:31 1990 *************** *** 82,88 **** setq("status", onev, &shvhed); #ifdef BSDJOBS if (tpgrp > 0) ! (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&tpgrp); #endif reset(); /* Unwind */ } --- 82,88 ---- setq("status", onev, &shvhed); #ifdef BSDJOBS if (tpgrp > 0) ! (void) tcsetpgrp(FSHTTY, tpgrp); #endif reset(); /* Unwind */ } *** sh.func.c.orig Thu Mar 29 11:14:02 1990 --- sh.func.c Fri Mar 30 13:45:04 1990 *************** *** 1348,1354 **** #ifdef BSDJOBS if (tpgrp != -1) { retry: ! (void) ioctl(FSHTTY, TIOCGPGRP, &ctpgrp); if (ctpgrp != opgrp) { old = sigsys(SIGTTIN, SIG_DFL); (void) kill(0, SIGTTIN); --- 1348,1354 ---- #ifdef BSDJOBS if (tpgrp != -1) { retry: ! ctpgrp = tcgetpgrp(FSHTTY); if (ctpgrp != opgrp) { old = sigsys(SIGTTIN, SIG_DFL); (void) kill(0, SIGTTIN); *************** *** 1355,1362 **** (void) sigsys(SIGTTIN, old); goto retry; } ! (void) ioctl(FSHTTY, TIOCSPGRP, &shpgrp); ! (void) setpgrp(0, shpgrp); } #endif /* BSDJOBS */ --- 1355,1362 ---- (void) sigsys(SIGTTIN, old); goto retry; } ! (void) setpgid(0, shpgrp); ! (void) tcsetpgrp(FSHTTY, shpgrp); } #endif /* BSDJOBS */ *** sh.h.orig Thu Mar 29 11:14:04 1990 --- sh.h Fri Mar 30 13:34:48 1990 *************** *** 95,101 **** #ifdef hpux # include <sys/bsdtty.h> ! # define setpgrp(a, b) setpgrp2(a, b) # define getpgrp(a) getpgrp2(a) #endif /* hpux */ --- 95,105 ---- #ifdef hpux # include <sys/bsdtty.h> ! # ifndef __hpux ! # define setpgrp(a, b) setpgrp2(a, b) ! # else ! # define POSIXJOBS ! # endif # define getpgrp(a) getpgrp2(a) #endif /* hpux */ *************** *** 186,191 **** --- 190,200 ---- # define bzero(a, b) memset(a, 0, b) # endif /* aiws */ #endif /* BSDSIGS */ + + #if defined(BSDJOBS) && !defined(POSIXJOBS) + #define setpgid(pid, pgrp) setpgrp(pid, pgrp) + #define tcsetpgrp(fd, pgrp) ioctl((fd), TIOCSPGRP, &(pgrp)) + #endif /* PWP: for everybody */ #define sigsys(s, a) signal(s, a) *** sh.init.c.orig Thu Mar 29 11:14:05 1990 --- sh.init.c Thu Mar 29 14:10:19 1990 *************** *** 369,375 **** /* 26 */ "VTALRM", "Virtual time alarm", /* 27 */ "PROF", "Profiling time alarm", ! # if defined(sun) || defined(ultrix) # define _sigextra_ /* 28 */ "WINCH", "Window changed", /* 29 */ "LOST", "Resource lost", --- 369,375 ---- /* 26 */ "VTALRM", "Virtual time alarm", /* 27 */ "PROF", "Profiling time alarm", ! # if defined(sun) || defined(ultrix) || defined(hp9000) # define _sigextra_ /* 28 */ "WINCH", "Window changed", /* 29 */ "LOST", "Resource lost", *** sh.proc.c.orig Thu Mar 29 11:14:18 1990 --- sh.proc.c Tue Apr 3 08:59:37 1990 *************** *** 18,26 **** #ifdef SVID # ifdef hpux /* ! * This version broke <sys/wait.h> moving backwards?? */ ! # include "ourwait.h" # else /* hpux */ # ifdef OREO # include <sys/wait.h> --- 18,31 ---- #ifdef SVID # ifdef hpux /* ! * 6.5 broke <sys/wait.h>, 7.0 fixed it again. */ ! # ifndef __hpux ! # include "ourwait.h" ! # else ! # define _BSD ! # include <sys/wait.h> ! # endif /* __hpux */ # else /* hpux */ # ifdef OREO # include <sys/wait.h> *************** *** 52,58 **** #define BIGINDEX 9 /* largest desirable job index */ #ifdef BSDTIMES ! # ifdef sun static struct rusage zru = { {0L, 0L}, {0L, 0L}, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L}; --- 57,63 ---- #define BIGINDEX 9 /* largest desirable job index */ #ifdef BSDTIMES ! # if defined(sun) || defined(hp9000) static struct rusage zru = { {0L, 0L}, {0L, 0L}, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L}; *************** *** 402,408 **** #endif #ifdef BSDJOBS if (tpgrp > 0) /* get tty back */ ! (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&tpgrp); #endif /* BSDJOBS */ if ((jobflags&(PSIGNALED|PSTOPPED|PTIME)) || !eq(dcwd->di_name, fp->p_cwd->di_name)) { --- 407,413 ---- #endif #ifdef BSDJOBS if (tpgrp > 0) /* get tty back */ ! (void) tcsetpgrp(FSHTTY, tpgrp); #endif /* BSDJOBS */ if ((jobflags&(PSIGNALED|PSTOPPED|PTIME)) || !eq(dcwd->di_name, fp->p_cwd->di_name)) { *************** *** 1184,1190 **** (void) pprint(pp, foregnd ? NAME|JOBDIR : NUMBER|NAME|AMPERSAND); #ifdef BSDJOBS if (foregnd) ! (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&pp->p_jobid); if (jobflags&PSTOPPED) (void) killpg(pp->p_jobid, SIGCONT); #endif /* BSDJOBS */ --- 1189,1195 ---- (void) pprint(pp, foregnd ? NAME|JOBDIR : NUMBER|NAME|AMPERSAND); #ifdef BSDJOBS if (foregnd) ! (void) tcsetpgrp(FSHTTY, pp->p_jobid); if (jobflags&PSTOPPED) (void) killpg(pp->p_jobid, SIGCONT); #endif /* BSDJOBS */ *************** *** 1534,1543 **** #endif /* OREO */ #ifdef BSDJOBS if (wanttty > 0) ! (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&pgrp); if (wanttty >= 0 && tpgrp >= 0) ! (void) setpgrp(0, pgrp); if (tpgrp > 0) tpgrp = 0; /* gave tty away */ #endif /* BSDJOBS */ --- 1539,1554 ---- #endif /* OREO */ #ifdef BSDJOBS + #ifdef POSIXJOBS + if (wanttty >= 0 && tpgrp >= 0) + (void) setpgid(0, pgrp); + #endif if (wanttty > 0) ! (void) tcsetpgrp(FSHTTY, pgrp); ! #ifndef POSIXJOBS if (wanttty >= 0 && tpgrp >= 0) ! (void) setpgid(0, pgrp); ! #endif if (tpgrp > 0) tpgrp = 0; /* gave tty away */ #endif /* BSDJOBS */ *** sh.lex.c.orig Thu Mar 29 11:14:05 1990 --- sh.lex.c Fri Mar 30 13:48:20 1990 *************** *** 1175,1185 **** goto oops; #ifdef BSDJOBS if (tpgrp != -1 && ! ioctl(FSHTTY, TIOCGPGRP, ! (char *)&ctpgrp) == 0 && tpgrp != ctpgrp) { ! (void) ioctl(FSHTTY, TIOCSPGRP, ! (char *)&tpgrp); (void) killpg(ctpgrp, SIGHUP); printf("Reset tty pgrp from %d to %d\n", ctpgrp, tpgrp); goto reread; --- 1175,1183 ---- goto oops; #ifdef BSDJOBS if (tpgrp != -1 && ! (ctpgrp = tcgetpgrp(FSHTTY)) != -1 && tpgrp != ctpgrp) { ! (void) tcsetpgrp(FSHTTY, tpgrp); (void) killpg(ctpgrp, SIGHUP); printf("Reset tty pgrp from %d to %d\n", ctpgrp, tpgrp); goto reread; *** sh.sem.c.orig Thu Mar 29 11:14:20 1990 --- sh.sem.c Tue Apr 3 09:00:13 1990 *************** *** 301,310 **** (void) sigsys(SIGQUIT, SIG_IGN); } #ifdef BSDJOBS if (wanttty > 0) ! (void) ioctl(FSHTTY, TIOCSPGRP, &pgrp); if (wanttty >= 0 && tpgrp >= 0) ! (void) setpgrp(0, pgrp); #endif /* BSDJOBS */ if (tpgrp > 0) tpgrp = 0; --- 301,316 ---- (void) sigsys(SIGQUIT, SIG_IGN); } #ifdef BSDJOBS + #ifdef POSIXJOBS + if (wanttty >= 0 && tpgrp >= 0) + (void) setpgid(0, pgrp); + #endif if (wanttty > 0) ! (void) tcsetpgrp(FSHTTY, pgrp); ! #ifndef POSIXJOBS if (wanttty >= 0 && tpgrp >= 0) ! (void) setpgid(0, pgrp); ! #endif #endif /* BSDJOBS */ if (tpgrp > 0) tpgrp = 0;