Subject: sigpending(2) bug, sigwait(2), tsleep added, much more (#427 2 of 2) Index: sys/kern_sig.c,kern_synch.c,many others 2.11BSD Description: See the first part (#426). Repeat-By: Fix: This is update #427 and is part 2 of 2. The manifest, narrative, instructions, and first half of the patches are in part 1. As always this and previous updates to 2.11BSD are available via anonymous FTP to either FTP.GD-ISO.COM or MOE.2BSD.COM in the directory /pub/2.11BSD. --------------------------cut here----------------------- *** /usr/src/sys/sys/kern_descrip.c.old Tue Mar 9 21:14:43 1999 --- /usr/src/sys/sys/kern_descrip.c Mon Sep 13 20:46:33 1999 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)kern_descrip.c 1.5 (2.11BSD) 1999/3/9 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)kern_descrip.c 1.6 (2.11BSD) 1999/9/13 */ #include "param.h" *************** *** 374,379 **** --- 374,380 ---- int how; } *uap = (struct a *)u.u_ap; register struct file *fp; + int error; if ((fp = getf(uap->fd)) == NULL) return; *************** *** 393,399 **** if ((fp->f_flag & FEXLOCK) && (uap->how & LOCK_EX) || (fp->f_flag & FSHLOCK) && (uap->how & LOCK_SH)) return; ! u.u_error = ino_lock(fp, uap->how); } /* --- 394,401 ---- if ((fp->f_flag & FEXLOCK) && (uap->how & LOCK_EX) || (fp->f_flag & FSHLOCK) && (uap->how & LOCK_SH)) return; ! error = ino_lock(fp, uap->how); ! return(u.u_error = error); } /* *** /usr/src/sys/sys/ufs_syscalls.c.old Fri Nov 28 16:51:33 1997 --- /usr/src/sys/sys/ufs_syscalls.c Mon Sep 13 20:30:36 1999 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ufs_syscalls.c 1.12 (2.11BSD GTE) 1997/11/28 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ufs_syscalls.c 1.13 (2.11BSD) 1999/9/13 */ #include "param.h" *************** *** 19,25 **** #include "quota.h" #endif ! static void copen(); /* * Change current working directory (``.''). --- 19,25 ---- #include "quota.h" #endif ! static int copen(); /* * Change current working directory (``.''). *************** *** 110,116 **** int crtmode; } *uap = (struct a *) u.u_ap; ! copen(uap->mode, uap->crtmode, uap->fname); } /* --- 110,116 ---- int crtmode; } *uap = (struct a *) u.u_ap; ! u.u_error = copen(uap->mode, uap->crtmode, uap->fname); } /* *************** *** 123,129 **** int fmode; } *uap = (struct a *)u.u_ap; ! copen(O_WRONLY|O_CREAT|O_TRUNC, uap->fmode, uap->fname); } /* --- 123,129 ---- int fmode; } *uap = (struct a *)u.u_ap; ! u.u_error = copen(O_WRONLY|O_CREAT|O_TRUNC, uap->fmode, uap->fname); } /* *************** *** 131,137 **** * Check permissions, allocate an open file structure, * and call the device open routine if any. */ ! static void copen(mode, arg, fname) int mode; int arg; --- 131,137 ---- * Check permissions, allocate an open file structure, * and call the device open routine if any. */ ! static int copen(mode, arg, fname) int mode; int arg; *************** *** 145,151 **** fp = falloc(); if (fp == NULL) ! return; flags = FFLAGS(mode); /* convert from open to kernel flags */ fp->f_flag = flags & FMASK; fp->f_type = DTYPE_INODE; --- 145,151 ---- fp = falloc(); if (fp == NULL) ! return(u.u_error); /* XXX */ flags = FFLAGS(mode); /* convert from open to kernel flags */ fp->f_flag = flags & FMASK; fp->f_type = DTYPE_INODE; *************** *** 174,185 **** (error = dupfdopen(indx,u.u_dupfd,flags,error) == 0)) { u.u_r.r_val1 = indx; ! u.u_error = 0; ! return; } u.u_ofile[indx] = NULL; ! u.u_error = error; /* XXX */ ! return; } ip = ndp->ni_ip; u.u_dupfd = 0; --- 174,183 ---- (error = dupfdopen(indx,u.u_dupfd,flags,error) == 0)) { u.u_r.r_val1 = indx; ! return(0); } u.u_ofile[indx] = NULL; ! return(error); } ip = ndp->ni_ip; u.u_dupfd = 0; *************** *** 201,208 **** u.u_ofile[indx] = NULL; } } ! u.u_error = error; ! return; } /* --- 199,205 ---- u.u_ofile[indx] = NULL; } } ! return(error); } /* *** /usr/src/sys/sys/kern_sig2.c.old Fri Sep 12 20:19:43 1997 --- /usr/src/sys/sys/kern_sig2.c Thu Sep 9 21:15:40 1999 *************** *** 35,41 **** * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ! * @(#)kern_sig.c 8.14.1 (2.11BSD) 1997/9/11 */ /* --- 35,41 ---- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ! * @(#)kern_sig.c 8.14.2 (2.11BSD) 1999/9/9 */ /* *************** *** 296,304 **** u.u_oldmask = p->p_sigmask; u.u_psflags |= SAS_OLDMASK; p->p_sigmask = nmask &~ sigcantmask; ! for (;;) ! sleep((caddr_t)&u, PSLEP); ! /* NOTREACHED */ } int --- 296,305 ---- u.u_oldmask = p->p_sigmask; u.u_psflags |= SAS_OLDMASK; p->p_sigmask = nmask &~ sigcantmask; ! while (tsleep((caddr_t)&u, PPAUSE|PCATCH, 0) == 0) ! ; ! /* always return EINTR rather than ERESTART */ ! return(u.u_error = EINTR); } int *************** *** 340,342 **** --- 341,379 ---- out: return(u.u_error = error); } + + int + sigwait() + { + register struct a { + sigset_t *set; + int *sig; + } *uap = (struct a *)u.u_ap; + sigset_t wanted, sigsavail; + register struct proc *p = u.u_procp; + int signo, error; + + if (uap->set == 0 || uap->sig == 0) + { + error = EINVAL; + goto out; + } + if (error = copyin(uap->set, &wanted, sizeof (sigset_t))) + goto out; + + wanted |= sigcantmask; + while ((sigsavail = (wanted & p->p_sig)) == 0) + tsleep(&u.u_signal[0], PPAUSE | PCATCH, 0); + + if (sigsavail & sigcantmask) + { + error = EINTR; + goto out; + } + + signo = ffs(sigsavail); + p->p_sig &= ~sigmask(signo); + error = copyout(&signo, uap->sig, sizeof (int)); + out: + return(u.u_error = error); + } *** /usr/src/sys/sys/syscalls.c.old Wed Dec 31 23:01:19 1997 --- /usr/src/sys/sys/syscalls.c Sun Sep 5 23:36:27 1999 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)syscalls.c 1.10 (2.11BSD GTE) 1997/12/31 */ /* --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)syscalls.c 1.11 (2.11BSD) 1999/9/5 */ /* *************** *** 62,73 **** "getegid", /* 48 = getegid */ "setgid", /* 49 = setgid */ "setegid", /* 50 = setegid */ ! "acct", /* 51 = turn acct off/on */ "phys", /* 52 = (2.9) set phys addr */ "lock", /* 53 = (2.9) lock in core */ "ioctl", /* 54 = ioctl */ "reboot", /* 55 = reboot */ ! "#56", /* 56 = unused */ "symlink", /* 57 = symlink */ "readlink", /* 58 = readlink */ "execve", /* 59 = execve */ --- 62,73 ---- "getegid", /* 48 = getegid */ "setgid", /* 49 = setgid */ "setegid", /* 50 = setegid */ ! "#51", /* 51 - unused */ "phys", /* 52 = (2.9) set phys addr */ "lock", /* 53 = (2.9) lock in core */ "ioctl", /* 54 = ioctl */ "reboot", /* 55 = reboot */ ! "sigwait", /* 56 = sigwait */ "symlink", /* 57 = symlink */ "readlink", /* 58 = readlink */ "execve", /* 59 = execve */ *** /usr/src/sys/sys/init_sysent.c.old Fri Feb 26 20:27:44 1999 --- /usr/src/sys/sys/init_sysent.c Sun Sep 5 23:36:48 1999 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)init_sysent.c 1.14 (2.11BSD) 1999/2/22 */ /* --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)init_sysent.c 1.15 (2.11BSD) 1999/9/5 */ /* *************** *** 35,41 **** /* 1.3 signals */ int sigvec(),sigblock(),sigsetmask(),sigpause(),sigstack(),sigreturn(); int sigaction(), sigprocmask(), sigpending(), sigaltstack(), sigsuspend(); ! int kill(), killpg(); /* 1.4 timing and statistics */ int gettimeofday(),settimeofday(); --- 35,41 ---- /* 1.3 signals */ int sigvec(),sigblock(),sigsetmask(),sigpause(),sigstack(),sigreturn(); int sigaction(), sigprocmask(), sigpending(), sigaltstack(), sigsuspend(); ! int sigwait(), kill(), killpg(); /* 1.4 timing and statistics */ int gettimeofday(),settimeofday(); *************** *** 167,173 **** 1, lock, /* 53 = (2.9) lock in core */ 4, ioctl, /* 54 = ioctl */ 1, reboot, /* 55 = reboot */ ! 0, nosys, /* 56 = unused */ 2, symlink, /* 57 = symlink */ 3, readlink, /* 58 = readlink */ 3, execve, /* 59 = execve */ --- 167,173 ---- 1, lock, /* 53 = (2.9) lock in core */ 4, ioctl, /* 54 = ioctl */ 1, reboot, /* 55 = reboot */ ! 2, sigwait, /* 56 = sigwait */ 2, symlink, /* 57 = symlink */ 3, readlink, /* 58 = readlink */ 3, execve, /* 59 = execve */ *** /usr/src/sys/sys/kern_exec.c.old Fri Nov 28 17:59:46 1997 --- /usr/src/sys/sys/kern_exec.c Mon Sep 6 10:10:41 1999 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)kern_exec.c 1.7 (2.11BSD GTE) 1997/11/28 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)kern_exec.c 1.8 (2.11BSD) 1999/9/6 */ #include "param.h" *************** *** 85,91 **** again: if (access(ip, IEXEC)) goto bad; ! if ((u.u_procp->p_flag&STRC) && access(ip, IREAD)) goto bad; if ((ip->i_mode & IFMT) != IFREG || (ip->i_mode & (IEXEC|(IEXEC>>3)|(IEXEC>>6))) == 0) { --- 85,91 ---- again: if (access(ip, IEXEC)) goto bad; ! if ((u.u_procp->p_flag & P_TRACED) && access(ip, IREAD)) goto bad; if ((ip->i_mode & IFMT) != IFREG || (ip->i_mode & (IEXEC|(IEXEC>>3)|(IEXEC>>6))) == 0) { *************** *** 603,609 **** /* * set SUID/SGID protections, if no tracing */ ! if ((u.u_procp->p_flag&STRC)==0) { u.u_uid = uid; u.u_procp->p_uid = uid; u.u_groups[0] = gid; --- 603,609 ---- /* * set SUID/SGID protections, if no tracing */ ! if ((u.u_procp->p_flag & P_TRACED)==0) { u.u_uid = uid; u.u_procp->p_uid = uid; u.u_groups[0] = gid; *** /usr/src/sys/sys/vm_sched.c.old Fri Mar 12 18:50:51 1993 --- /usr/src/sys/sys/vm_sched.c Fri Sep 10 19:54:22 1999 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)vm_sched.c 1.1 (2.10BSD Berkeley) 12/1/86 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)vm_sched.c 1.2 (2.11BSD) 1999/9/10 */ #include "param.h" *************** *** 79,85 **** /* * None found. Look around for core: 1) kick out dead wood * (processes asleep longer than maxslp+10); or 2) select out ! * of the processes sleeping at bad priority the process with * maximum f(size, slptime); or 3) if none, select the oldest. * If we can find someone to swap out we try to swap someone * else (hopefully) in, possibly causing someone else to get --- 79,85 ---- /* * None found. Look around for core: 1) kick out dead wood * (processes asleep longer than maxslp+10); or 2) select out ! * of the processes sleeping interruptibly the process with * maximum f(size, slptime); or 3) if none, select the oldest. * If we can find someone to swap out we try to swap someone * else (hopefully) in, possibly causing someone else to get *************** *** 104,110 **** if (rp->p_textp && rp->p_textp->x_flag & XLOCK) continue; if (rp->p_stat == SSLEEP && ! rp->p_pri > PZERO || rp->p_stat == SSTOP) { register int size; if (rp->p_slptime > maxslp+10) { --- 104,110 ---- if (rp->p_textp && rp->p_textp->x_flag & XLOCK) continue; if (rp->p_stat == SSLEEP && ! (rp->p_flag & P_SINTR) || rp->p_stat == SSTOP) { register int size; if (rp->p_slptime > maxslp+10) { *************** *** 137,143 **** noop(); (void)_splhigh(); /* ! * Swap found user out if sleeping at bad pri, or if he has spent at * least 1 second in core and the swapped-out process has spent at * least 2 seconds out. Otherwise wait a bit and try again. */ --- 137,143 ---- noop(); (void)_splhigh(); /* ! * Swap found user out if sleeping interruptibly, or if he has spent at * least 1 second in core and the swapped-out process has spent at * least 2 seconds out. Otherwise wait a bit and try again. */ *************** *** 235,245 **** case SSLEEP: case SSTOP: ! if (p->p_pri <= PZERO && p->p_stat == SSLEEP) nrun++; #ifdef UCB_METER if (p->p_flag & SLOAD) { ! if (p->p_pri <= PZERO) total.t_dw++; else if (p->p_slptime < maxslp) total.t_sl++; --- 235,245 ---- case SSLEEP: case SSTOP: ! if (!(p->p_flag & P_SINTR) && p->p_stat == SSLEEP) nrun++; #ifdef UCB_METER if (p->p_flag & SLOAD) { ! if (!(p->p_flag & P_SINTR)) total.t_dw++; else if (p->p_slptime < maxslp) total.t_sl++; *** /usr/src/sys/sys/vfs_vnops.c.old Fri Feb 7 21:33:27 1997 --- /usr/src/sys/sys/vfs_vnops.c Mon Sep 13 20:15:35 1999 *************** *** 35,41 **** * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ! * @(#)vfs_vnops.c 8.14.3 (2.11BSD) 1997/2/7 */ #include --- 35,41 ---- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ! * @(#)vfs_vnops.c 8.14.4 (2.11BSD) 1999/9/13 */ #include *************** *** 147,154 **** iunlock(ip); /* because namei returns a locked inode */ if (setjmp(&u.u_qsave)) { ! if ((error = u.u_error) == 0) ! error = EINTR; goto lbad; } if (error = openi(ip, fmode)) --- 147,153 ---- iunlock(ip); /* because namei returns a locked inode */ if (setjmp(&u.u_qsave)) { ! error = EINTR; /* opens are not restarted after signals */ goto lbad; } if (error = openi(ip, fmode)) *** /usr/src/sys/sys/uipc_syscalls.c.old Fri Dec 2 23:21:52 1994 --- /usr/src/sys/sys/uipc_syscalls.c Mon Sep 13 21:01:50 1999 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)uipc_syscalls.c 7.1.2 (2.11BSD GTE) 12/2/94 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)uipc_syscalls.c 7.1.3 (2.11BSD) 1999/9/13 */ #include "param.h" *************** *** 224,234 **** * sleep()" loop. */ s = splnet(); ! if (setjmp(&u.u_qsave)) { ! if (u.u_error == 0) ! u.u_error = EINTR; goto bad2; ! } u.u_error = CONNWHILE(so); bad2: splx(s); --- 224,234 ---- * sleep()" loop. */ s = splnet(); ! if (setjmp(&u.u_qsave)) ! { ! u.u_error = EINTR; goto bad2; ! } u.u_error = CONNWHILE(so); bad2: splx(s); *************** *** 246,264 **** struct socket *so1, *so2; int sv[2]; ! #ifndef pdp11 ! if (useracc((caddr_t)uap->rsv, 2 * sizeof (int), B_WRITE) == 0) { ! u.u_error = EFAULT; ! return; ! } ! #endif ! if (netoff) return(u.u_error = ENETDOWN); u.u_error = SOCREATE(uap->domain, &so1, uap->type, uap->protocol); ! if (u.u_error) return; u.u_error = SOCREATE(uap->domain, &so2, uap->type, uap->protocol); ! if (u.u_error) goto free; fp1 = falloc(); if (fp1 == NULL) --- 246,258 ---- struct socket *so1, *so2; int sv[2]; ! if (netoff) return(u.u_error = ENETDOWN); u.u_error = SOCREATE(uap->domain, &so1, uap->type, uap->protocol); ! if (u.u_error) return; u.u_error = SOCREATE(uap->domain, &so2, uap->type, uap->protocol); ! if (u.u_error) goto free; fp1 = falloc(); if (fp1 == NULL) *************** *** 397,419 **** auio.uio_resid = 0; auio.uio_rw = UIO_WRITE; iov = mp->msg_iov; ! for (i = 0; i < mp->msg_iovlen; i++, iov++) { ! #ifndef pdp11 ! if (iov->iov_len < 0) { ! u.u_error = EINVAL; ! return; ! } ! #endif ! if (iov->iov_len == 0) continue; - #ifndef pdp11 - if (useracc(iov->iov_base, (u_int)iov->iov_len, B_READ) == 0) { - u.u_error = EFAULT; - return; - } - #endif auio.uio_resid += iov->iov_len; ! } if (mp->msg_name) { to = (struct mbuf *)sabuf; MBZAP(to, mp->msg_namelen, MT_SONAME); --- 391,402 ---- auio.uio_resid = 0; auio.uio_rw = UIO_WRITE; iov = mp->msg_iov; ! for (i = 0; i < mp->msg_iovlen; i++, iov++) ! { ! if (iov->iov_len == 0) continue; auio.uio_resid += iov->iov_len; ! } if (mp->msg_name) { to = (struct mbuf *)sabuf; MBZAP(to, mp->msg_namelen, MT_SONAME); *************** *** 435,441 **** } else rights = 0; len = auio.uio_resid; ! u.u_error = SOSEND(fp->f_socket, to, &auio, flags, rights); u.u_r.r_val1 = len - auio.uio_resid; } --- 418,432 ---- } else rights = 0; len = auio.uio_resid; ! if (setjmp(&u.u_qsave)) ! { ! if (auio.uio_resid == len) ! return; ! else ! u.u_error = 0; ! } ! else ! u.u_error = SOSEND(fp->f_socket, to, &auio, flags, rights); u.u_r.r_val1 = len - auio.uio_resid; } *************** *** 542,567 **** auio.uio_resid = 0; auio.uio_rw = UIO_READ; iov = mp->msg_iov; ! for (i = 0; i < mp->msg_iovlen; i++, iov++) { ! #ifndef pdp11 ! if (iov->iov_len < 0) { ! u.u_error = EINVAL; ! return; ! } ! #endif ! if (iov->iov_len == 0) continue; - #ifndef pdp11 - if (useracc(iov->iov_base, (u_int)iov->iov_len, B_WRITE) == 0) { - u.u_error = EFAULT; - return; - } - #endif auio.uio_resid += iov->iov_len; ! } len = auio.uio_resid; ! u.u_error = ! SORECEIVE((struct socket *)fp->f_data, &from, &auio,flags, &rights); u.u_r.r_val1 = len - auio.uio_resid; if (mp->msg_name) { len = mp->msg_namelen; --- 533,557 ---- auio.uio_resid = 0; auio.uio_rw = UIO_READ; iov = mp->msg_iov; ! for (i = 0; i < mp->msg_iovlen; i++, iov++) ! { ! if (iov->iov_len == 0) continue; auio.uio_resid += iov->iov_len; ! } len = auio.uio_resid; ! if (setjmp(&u.u_qsave)) ! { ! if (auio.uio_resid == len) ! return; ! else ! u.u_error = 0; ! } ! else ! u.u_error = SORECEIVE((struct socket *)fp->f_data, ! &from, &auio,flags, &rights); ! if (u.u_error) ! return; u.u_r.r_val1 = len - auio.uio_resid; if (mp->msg_name) { len = mp->msg_namelen; *** /usr/src/sys/h/proc.h.old Wed Aug 11 20:12:28 1999 --- /usr/src/sys/h/proc.h Sun Sep 5 22:07:08 1999 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)proc.h 1.4 (2.11BSD) 1999/8/11 */ #ifndef _SYS_PROC_H_ --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)proc.h 1.5 (2.11BSD) 1999/9/5 */ #ifndef _SYS_PROC_H_ *************** *** 43,49 **** char P_time; /* resident time for scheduling */ char P_nice; /* nice for cpu usage */ char P_slptime; /* secs sleeping */ ! char P_cursig; struct proc *P_hash; /* hashed based on p_pid */ long P_sigmask; /* current signal mask */ long P_sigignore; /* signals being ignored */ --- 43,49 ---- char P_time; /* resident time for scheduling */ char P_nice; /* nice for cpu usage */ char P_slptime; /* secs sleeping */ ! char P_ptracesig; /* used between parent & traced child */ struct proc *P_hash; /* hashed based on p_pid */ long P_sigmask; /* current signal mask */ long P_sigignore; /* signals being ignored */ *************** *** 71,77 **** #define p_nice p_un.p_alive.P_nice #define p_slptime p_un.p_alive.P_slptime #define p_hash p_un.p_alive.P_hash ! #define p_cursig p_un.p_alive.P_cursig #define p_sigmask p_un.p_alive.P_sigmask #define p_sigignore p_un.p_alive.P_sigignore #define p_sigcatch p_un.p_alive.P_sigcatch --- 71,77 ---- #define p_nice p_un.p_alive.P_nice #define p_slptime p_un.p_alive.P_slptime #define p_hash p_un.p_alive.P_hash ! #define p_ptracesig p_un.p_alive.P_ptracesig #define p_sigmask p_un.p_alive.P_sigmask #define p_sigignore p_un.p_alive.P_sigignore #define p_sigcatch p_un.p_alive.P_sigcatch *************** *** 115,131 **** #define SSYS 0x0002 /* swapper or pager process */ #define SLOCK 0x0004 /* process being swapped out */ #define SSWAP 0x0008 /* save area flag */ ! #define STRC 0x0010 /* process is being traced */ ! #define SWTED 0x0020 /* another tracing flag */ #define SULOCK 0x0040 /* user settable lock in core */ ! /* 0x0080 /* used to be SOMASK */ #define SVFORK 0x0100 /* process resulted from vfork() */ #define SVFPRNT 0x0200 /* parent in vfork, waiting for child */ #define SVFDONE 0x0400 /* parent has released child in vfork */ /* 0x0800 /* unused */ ! /* 0x1000 /* used to be SDETACH */ #define P_NOCLDSTOP 0x2000 /* no SIGCHLD signal to parent */ ! #define SSEL 0x4000 /* selecting; wakeup/waiting danger */ /* 0x8000 /* unused */ #define S_DATA 0 /* specified segment */ --- 115,131 ---- #define SSYS 0x0002 /* swapper or pager process */ #define SLOCK 0x0004 /* process being swapped out */ #define SSWAP 0x0008 /* save area flag */ ! #define P_TRACED 0x0010 /* process is being traced */ ! #define P_WAITED 0x0020 /* another tracing flag */ #define SULOCK 0x0040 /* user settable lock in core */ ! #define P_SINTR 0x0080 /* sleeping interruptibly */ #define SVFORK 0x0100 /* process resulted from vfork() */ #define SVFPRNT 0x0200 /* parent in vfork, waiting for child */ #define SVFDONE 0x0400 /* parent has released child in vfork */ /* 0x0800 /* unused */ ! #define P_TIMEOUT 0x1000 /* tsleep timeout expired */ #define P_NOCLDSTOP 0x2000 /* no SIGCHLD signal to parent */ ! #define P_SELECT 0x4000 /* selecting; wakeup/waiting danger */ /* 0x8000 /* unused */ #define S_DATA 0 /* specified segment */ *** /usr/src/sys/h/param.h.old Tue Sep 2 19:03:42 1997 --- /usr/src/sys/h/param.h Wed Sep 15 19:38:45 1999 *************** *** 3,29 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)param.h 1.5 (2.11BSD GTE) 1997/9/2 */ #define BSD 211 /* 2.11 * 10, as cpp doesn't do floats */ - #ifdef KERNEL - #include "localopts.h" - #else #include - #endif - #include /* for 'offsetof' */ /* * Machine type dependent parameters. */ - #ifdef KERNEL - #include "../machine/machparam.h" - #else #include - #endif /* * Machine-independent constants --- 3,20 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)param.h 1.6 (2.11BSD) 1999/9/5 */ #define BSD 211 /* 2.11 * 10, as cpp doesn't do floats */ #include #include /* for 'offsetof' */ /* * Machine type dependent parameters. */ #include /* * Machine-independent constants *************** *** 46,74 **** #define PRIUBA 24 #define PZERO 25 #define PPIPE 26 #define PWAIT 30 #define PLOCK 35 ! #define PSLEP 40 #define PUSER 50 #define NZERO 0 /* * Signals */ - #ifdef KERNEL - #include "signal.h" - #else #include - #endif - #define ISSIG(p) \ - ((p)->p_sig && ((p)->p_flag&STRC || \ - ((p)->p_sig &~ ((p)->p_sigignore | (p)->p_sigmask))) && issig()) - #define NBPW sizeof(int) /* number of bytes in an integer */ #define NULL 0 #define CMASK 026 /* default mask for file creation */ #define NODEV (dev_t)(-1) --- 37,63 ---- #define PRIUBA 24 #define PZERO 25 #define PPIPE 26 + #define PSOCK 26 #define PWAIT 30 #define PLOCK 35 ! #define PPAUSE 40 #define PUSER 50 #define NZERO 0 + #define PRIMASK 0xff + #define PCATCH 0x100 + /* * Signals */ #include #define NBPW sizeof(int) /* number of bytes in an integer */ + #ifndef NULL #define NULL 0 + #endif #define CMASK 026 /* default mask for file creation */ #define NODEV (dev_t)(-1) *************** *** 86,96 **** #define CBSIZE (CBLOCK - sizeof(struct cblock *)) /* data chars/clist */ #define CROUND (CBLOCK - 1) /* clist rounding */ - #ifndef KERNEL #include - #else - #include "types.h" - #endif /* * File system parameters and macros. --- 75,81 ---- *** /usr/src/sys/h/signalvar.h.old Fri Aug 29 13:34:58 1997 --- /usr/src/sys/h/signalvar.h Mon Sep 6 09:52:43 1999 *************** *** 30,36 **** * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ! * @(#)signalvar.h 8.6.1 (Berkeley) 1997/8/28 */ #ifndef _SYS_SIGNALVAR_H_ /* tmp for user.h */ --- 30,36 ---- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ! * @(#)signalvar.h 8.6.2 (2.11BSD) 1999/9/6 */ #ifndef _SYS_SIGNALVAR_H_ /* tmp for user.h */ *************** *** 50,55 **** --- 50,69 ---- /* additional signal action values, used only temporarily/internally */ #define SIG_CATCH (int (*)())2 #define SIG_HOLD (int (*)())3 + + /* + * Determine signal that should be delivered to process p, the current + * process, 0 if none. If there is a pending stop signal with default + * action, the process stops in issignal(). + * + * This probably should be a routine (assembly) instead of a macro due + * to the voluminous code generated by all of the 'long' operations. + */ + #define CURSIG(p) \ + (((p)->p_sig == 0 || \ + (((p)->p_flag & P_TRACED) == 0 && \ + ((p)->p_sig & ~(p)->p_sigmask) == 0)) ? \ + 0 : issignal(p)) /* * Signal properties and actions. *** /usr/src/sys/h/errno.h.old Thu Dec 26 13:53:29 1991 --- /usr/src/sys/h/errno.h Mon Sep 6 10:08:14 1999 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)errno.h 7.1.2 (2.11BSD GTE) 1995/12/26 */ #ifndef KERNEL --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)errno.h 7.1.3 (2.11BSD) 1999/9/6 */ #ifndef KERNEL *************** *** 113,115 **** --- 113,121 ---- #define EAUTH 80 /* Authentication error */ #define ENEEDAUTH 81 /* Need authenticator */ #define ELAST 81 /* Must be equal largest errno */ + + #ifdef KERNEL + /* pseudo-errors returned inside kernel to modify return back to user mode */ + #define ERESTART -1 /* restart syscall */ + #define EJUSTRETURN -2 /* don't modify regs, just return */ + #endif *** /usr/src/sys/h/user.h.old Fri Nov 28 16:21:56 1997 --- /usr/src/sys/h/user.h Mon Sep 13 20:55:34 1999 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)user.h 1.5 (2.11BSD) 1997/11/28 */ #ifdef KERNEL --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)user.h 1.6 (2.11BSD) 1999/9/13 */ #ifdef KERNEL *************** *** 62,68 **** time_t r_time; } u_r; char u_error; /* return error code */ ! char u_eosys; /* special action on end of syscall */ /* 1.1 - processes and protection */ uid_t u_uid; /* effective user id */ --- 62,68 ---- time_t r_time; } u_r; char u_error; /* return error code */ ! char u_dummy0; /* 1.1 - processes and protection */ uid_t u_uid; /* effective user id */ *************** *** 147,162 **** */ }; ! #define JUSTRETURN 1 ! #define RESTARTSYS 2 ! #define NORMALRETURN 3 ! ! /* u_error codes */ ! #ifdef KERNEL ! #include "errno.h" ! #else ! #include ! #endif #ifdef KERNEL extern struct user u; --- 147,153 ---- */ }; ! #include #ifdef KERNEL extern struct user u; *** /usr/src/sys/pdp/trap.c.old Mon Sep 1 18:50:19 1997 --- /usr/src/sys/pdp/trap.c Mon Sep 13 21:04:42 1999 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)trap.c 1.5 (2.11BSD GTE) 1997/8/26 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)trap.c 1.6 (2.11BSD) 1999/9/13 */ #include "param.h" *************** *** 298,305 **** } psignal(p, i); out: ! if (p->p_cursig || ISSIG(p)) ! postsig(); curpri = setpri(p); if (runrun) { setrq(u.u_procp); --- 298,305 ---- } psignal(p, i); out: ! while (i = CURSIG(p)) ! postsig(i); curpri = setpri(p); if (runrun) { setrq(u.u_procp); *************** *** 328,333 **** --- 328,334 ---- register struct sysent *callp; time_t syst; register caddr_t opc; /* original pc for restarting syscalls */ + int i; #ifdef UCB_METER cnt.v_syscall++; *************** *** 347,378 **** copyin(sp+2, (caddr_t)u.u_arg, callp->sy_narg*NBPW); u.u_r.r_val1 = 0; u.u_r.r_val2 = r1; ! if (setjmp(&u.u_qsave)) { ! if (u.u_error == 0 && u.u_eosys != RESTARTSYS) ! u.u_error = EINTR; ! } else { ! u.u_eosys = NORMALRETURN; (*callp->sy_call)(); ! #ifdef DIAGNOSTIC ! if (hasmap) panic("hasmap"); #endif ! } ! if (u.u_eosys == NORMALRETURN) { ! if (u.u_error) { ! ps |= PSL_C; ! r0 = u.u_error; ! } else { ps &= ~PSL_C; r0 = u.u_r.r_val1; r1 = u.u_r.r_val2; } ! } else if (u.u_eosys == RESTARTSYS) ! pc = opc; /* back up pc to restart syscall */ ! /* else if (u.u_eosys == JUSTRETURN) */ ! /* nothing to do */ ! if (u.u_procp->p_cursig || ISSIG(u.u_procp)) ! postsig(); curpri = setpri(u.u_procp); if (runrun) { setrq(u.u_procp); --- 348,380 ---- copyin(sp+2, (caddr_t)u.u_arg, callp->sy_narg*NBPW); u.u_r.r_val1 = 0; u.u_r.r_val2 = r1; ! if (setjmp(&u.u_qsave) == 0) ! { (*callp->sy_call)(); ! #ifdef DIAGNOSTIC ! if (hasmap) panic("hasmap"); #endif ! } ! switch (u.u_error) ! { ! case 0: ps &= ~PSL_C; r0 = u.u_r.r_val1; r1 = u.u_r.r_val2; + break; + case ERESTART: + pc = opc; + break; + case EJUSTRETURN: + break; + default: + ps |= PSL_C; + r0 = u.u_error; + break; } ! while (i = CURSIG(u.u_procp)) ! postsig(i); curpri = setpri(u.u_procp); if (runrun) { setrq(u.u_procp); *** /usr/src/sys/pdp/machdep.c.old Sat Aug 30 16:22:55 1997 --- /usr/src/sys/pdp/machdep.c Mon Sep 13 20:48:14 1999 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)machdep.c 2.3 (2.11BSD) 1997/8/26 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)machdep.c 2.4 (2.11BSD) 1999/9/13 */ #include "param.h" *************** *** 142,148 **** u.u_error = EINVAL; return; } ! u.u_eosys = JUSTRETURN; if (scp->sc_onstack & SA_ONSTACK) u.u_sigstk.ss_flags |= SA_ONSTACK; else --- 142,148 ---- u.u_error = EINVAL; return; } ! u.u_error = EJUSTRETURN; if (scp->sc_onstack & SA_ONSTACK) u.u_sigstk.ss_flags |= SA_ONSTACK; else *** /usr/src/libexec/comsat/comsat.c.old Sat Nov 16 19:06:39 1996 --- /usr/src/libexec/comsat/comsat.c Wed Sep 15 19:44:05 1999 *************** *** 15,23 **** "@(#) Copyright (c) 1980 Regents of the University of California.\n\ All rights reserved.\n"; ! static char sccsid[] = "@(#)comsat.c 5.11.1 (2.11BSD) 1996/11/16"; #endif #include #include #include --- 15,25 ---- "@(#) Copyright (c) 1980 Regents of the University of California.\n\ All rights reserved.\n"; ! static char sccsid[] = "@(#)comsat.c 5.11.2 (2.11BSD) 1999/9/15"; #endif + #include + #include #include #include #include *************** *** 57,62 **** --- 59,65 ---- char msgbuf[100]; struct sockaddr_in from; int fromlen, reapchildren(), onalrm(); + sigset_t set, oset; /* verify proper invocation */ fromlen = sizeof (from); *************** *** 84,107 **** for (;;) { cc = recv(0, msgbuf, sizeof (msgbuf) - 1, 0); if (cc <= 0) { ! if (errno != EINTR) ! sleep(1); ! errno = 0; continue; } if (!nutmp) /* no one has logged in yet */ continue; ! sigblock(sigmask(SIGALRM)); msgbuf[cc] = 0; (void)time(&lastmsgtime); mailfor(msgbuf); ! sigsetmask(0L); } } reapchildren() { ! while (wait3((union wait *)NULL, WNOHANG, (struct rusage *)NULL) > 0); } onalrm() --- 87,111 ---- for (;;) { cc = recv(0, msgbuf, sizeof (msgbuf) - 1, 0); if (cc <= 0) { ! sleep(1); continue; } if (!nutmp) /* no one has logged in yet */ continue; ! sigemptyset(&set); ! sigaddset(&set, SIGALRM); ! sigprocmask(SIG_BLOCK, &set, &oset); msgbuf[cc] = 0; (void)time(&lastmsgtime); mailfor(msgbuf); ! sigprocmask(SIG_SETMASK, &oset, NULL); } } reapchildren() { ! while (wait4(-1, NULL, WNOHANG, NULL) > 0) ! ; } onalrm() *************** *** 109,116 **** static u_int utmpsize; /* last malloced size for utmp */ static u_int utmpmtime; /* last modification time for utmp */ struct stat statbf; - off_t lseek(); - char *malloc(), *realloc(); if (time((time_t *)NULL) - lastmsgtime >= MAXIDLE) exit(0); --- 113,118 ---- *************** *** 139,145 **** { register struct utmp *utp = &utmp[nutmp]; register char *cp; ! off_t offset, atol(); if (!(cp = index(name, '@'))) return; --- 141,147 ---- { register struct utmp *utp = &utmp[nutmp]; register char *cp; ! off_t offset; if (!(cp = index(name, '@'))) return; *************** *** 194,202 **** { register char *cp; register FILE *fi; ! register int linecnt, charcnt, inheader; char line[BUFSIZ]; - off_t fseek(); if ((fi = fopen(name, "r")) == NULL) return; --- 196,203 ---- { register char *cp; register FILE *fi; ! int linecnt, charcnt, inheader; char line[BUFSIZ]; if ((fi = fopen(name, "r")) == NULL) return; *** /usr/src/lib/libc/pdp/sys/Makefile.old Fri Feb 19 17:06:04 1999 --- /usr/src/lib/libc/pdp/sys/Makefile Fri Sep 10 20:36:21 1999 *************** *** 1,6 **** # Placed in the public domain - 1995/05/06 # ! # @(#)Makefile 1.7 (2.11BSD) 1999/2/19 CPP= /lib/cpp LD= /bin/ld --- 1,6 ---- # Placed in the public domain - 1995/05/06 # ! # @(#)Makefile 1.8 (2.11BSD) 1999/9/10 CPP= /lib/cpp LD= /bin/ld *************** *** 33,39 **** setuid.o seteuid.o setgid.o setegid.o \ setrlimit.o setsockopt.o settimeofday.o \ shutdown.o sigaltstack.o socket.o socketpair.o stat.o symlink.o \ ! sigprocmask.o sigstack.o \ statfs.o fstatfs.o getfsstat.o \ truncate.o umount.o unlink.o utimes.o wait4.o write.o writev.o --- 33,39 ---- setuid.o seteuid.o setgid.o setegid.o \ setrlimit.o setsockopt.o settimeofday.o \ shutdown.o sigaltstack.o socket.o socketpair.o stat.o symlink.o \ ! sigprocmask.o sigstack.o sigwait.o \ statfs.o fstatfs.o getfsstat.o \ truncate.o umount.o unlink.o utimes.o wait4.o write.o writev.o *** /usr/src/man/man2/select.2.old Sun Dec 14 15:07:05 1986 --- /usr/src/man/man2/select.2 Fri Sep 10 20:22:42 1999 *************** *** 2,10 **** .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" ! .\" @(#)select.2 6.5 (Berkeley) 5/15/86 .\" ! .TH SELECT 2 "May 15, 1986" .UC 5 .SH NAME select \- synchronous I/O multiplexing --- 2,10 ---- .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" ! .\" @(#)select.2 6.5.1 (2.11BSD) 1999/9/10 .\" ! .TH SELECT 2 "September 10, 1999" .UC 5 .SH NAME select \- synchronous I/O multiplexing *************** *** 144,146 **** --- 144,153 ---- by the .I select call. + .PP + In 2BSD the timeout is implemented in the kernel using the \fIcallout\fP + table. Since a \fIcallout\fP structure only has a signed short to + store the number of ticks till expiration the maximum value of a kernel + timeout is 32767 ticks. In the US (60hz power) this gives a maximum + timeout of approximately 9 minutes. In countries using 50hz power + the maximum timeout is about 13 minutes. *** /usr/src/man/man2/Makefile.old Mon Dec 8 21:57:24 1997 --- /usr/src/man/man2/Makefile Fri Sep 10 21:09:55 1999 *************** *** 14,20 **** # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # ! # @(#)Makefile 2.9 (2.11BSD GTE) 1997/12/8 # MDIR= /usr/man/cat2 SRCS= accept.2 access.2 acct.2 adjtime.2 bind.2 brk.2 chdir.2 chmod.2 \ --- 14,20 ---- # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # ! # @(#)Makefile 2.10 (2.11BSD) 1999/9/10 # MDIR= /usr/man/cat2 SRCS= accept.2 access.2 acct.2 adjtime.2 bind.2 brk.2 chdir.2 chmod.2 \ *************** *** 32,38 **** recv.2 rename.2 rmdir.2 select.2 send.2 setgroups.2 setpgrp.2 \ setquota.2 shutdown.2 sigblock.2 sigpause.2 \ sigaction.2 sigaltstack.2 sigpending.2 sigprocmask.2 sigsuspend.2 \ ! sigreturn.2 sigsetmask.2 sigstack.2 sigvec.2 socket.2 socketpair.2 \ stat.2 statfs.2 swapon.2 symlink.2 sync.2 syscall.2 truncate.2 ucall.2 \ umask.2 unlink.2 utimes.2 vfork.2 vhangup.2 wait.2 write.2 OBJS= accept.0 access.0 acct.0 adjtime.0 bind.0 brk.0 chdir.0 chmod.0 \ --- 32,39 ---- recv.2 rename.2 rmdir.2 select.2 send.2 setgroups.2 setpgrp.2 \ setquota.2 shutdown.2 sigblock.2 sigpause.2 \ sigaction.2 sigaltstack.2 sigpending.2 sigprocmask.2 sigsuspend.2 \ ! sigreturn.2 sigsetmask.2 sigstack.2 sigwait.2 sigvec.2 socket.2 \ ! socketpair.2 \ stat.2 statfs.2 swapon.2 symlink.2 sync.2 syscall.2 truncate.2 ucall.2 \ umask.2 unlink.2 utimes.2 vfork.2 vhangup.2 wait.2 write.2 OBJS= accept.0 access.0 acct.0 adjtime.0 bind.0 brk.0 chdir.0 chmod.0 \ *************** *** 50,56 **** recv.0 rename.0 rmdir.0 select.0 send.0 setgroups.0 setpgrp.0 \ setquota.0 shutdown.0 sigblock.0 sigpause.0 \ sigaction.0 sigaltstack.0 sigpending.0 sigprocmask.0 sigsuspend.0 \ ! sigreturn.0 sigsetmask.0 sigstack.0 sigvec.0 socket.0 socketpair.0 \ stat.0 statfs.0 swapon.0 symlink.0 sync.0 syscall.0 truncate.0 ucall.0 \ umask.0 unlink.0 utimes.0 vfork.0 vhangup.0 wait.0 write.0 --- 51,58 ---- recv.0 rename.0 rmdir.0 select.0 send.0 setgroups.0 setpgrp.0 \ setquota.0 shutdown.0 sigblock.0 sigpause.0 \ sigaction.0 sigaltstack.0 sigpending.0 sigprocmask.0 sigsuspend.0 \ ! sigreturn.0 sigsetmask.0 sigstack.0 sigwait.0 sigvec.0 socket.0 \ ! socketpair.0 \ stat.0 statfs.0 swapon.0 symlink.0 sync.0 syscall.0 truncate.0 ucall.0 \ umask.0 unlink.0 utimes.0 vfork.0 vhangup.0 wait.0 write.0 *** /usr/src/new/crash/crashsubs.c.old Wed Aug 11 20:43:39 1999 --- /usr/src/new/crash/crashsubs.c Tue Sep 14 21:15:49 1999 *************** *** 1,6 **** --- 1,9 ---- /* * U N I X 2 . 9 B S D C R A S H A N A L Y Z E R S U B S * + * More proc struct flag changes. No progress (no effort either ;)) on + * getting the program to compile - 1999/9/14 + * * Another proc struct flag went away. Program still doesn't run or * compile ;-( 1999/8/11 * *************** *** 578,584 **** procflg(flgs) int *flgs; { ! #define PROC_FLAGS "\0\1SLOAD\2SSYS\3SLOCK\4SSWAP\5STRC\6SWTED\7SULOCK\11SVFORK\12SVFPRNT\13SVFDONE\16P_NOCLDSTOP\17SSEL" printb((u_long) *flgs, PROC_FLAGS); } --- 581,587 ---- procflg(flgs) int *flgs; { ! #define PROC_FLAGS "\0\1SLOAD\2SSYS\3SLOCK\4SSWAP\5P_TRACED\6P_WAITED\7SULOCK\8P_SINTR\11SVFORK\12SVFPRNT\13SVFDONE\15P_TIMEOUT\16P_NOCLDSTOP\17P_SELECT" printb((u_long) *flgs, PROC_FLAGS); } *** /usr/src/share/adb/u.old Fri Nov 28 17:14:28 1997 --- /usr/src/share/adb/u Tue Sep 14 20:06:29 1999 *************** *** 1,10 **** ./"pcb"non"u_fpsr"ndn"u_fpregs"n6Fn"u_fpsaved"ndn"f_fec"8t"f_fea"ndon ! +/"u_proc"non"u_ar0"non"u_comm"n15C+n"u_arg"n6on +/"u_ap"non +/"qsave"n +$<