svn commit: r190847 - head/sys/kern
Ed Schouten
ed at FreeBSD.org
Wed Apr 8 08:56:52 PDT 2009
Author: ed
Date: Wed Apr 8 15:56:50 2009
New Revision: 190847
URL: http://svn.freebsd.org/changeset/base/190847
Log:
Fix tty_wait_background() to comply with standards.
It turns out my handling of SIGTTOU and SIGTTIN didn't entirely comply
to the standards. It is true that in the SIGTTOU case we should not
return EIO when the signal is ignored/blocked, but in the SIGTTIN case
we must.
See also: POSIX issue 7 section 11.1.4
Modified:
head/sys/kern/tty.c
Modified: head/sys/kern/tty.c
==============================================================================
--- head/sys/kern/tty.c Wed Apr 8 15:18:21 2009 (r190846)
+++ head/sys/kern/tty.c Wed Apr 8 15:56:50 2009 (r190847)
@@ -371,23 +371,31 @@ tty_wait_background(struct tty *tp, stru
* exit
* - the signal to send to the process isn't masked
*/
- if (!tty_is_ctty(tp, p) ||
- p->p_pgrp == tp->t_pgrp || p->p_flag & P_PPWAIT ||
- SIGISMEMBER(p->p_sigacts->ps_sigignore, sig) ||
- SIGISMEMBER(td->td_sigmask, sig)) {
+ if (!tty_is_ctty(tp, p) || p->p_pgrp == tp->t_pgrp) {
/* Allow the action to happen. */
PROC_UNLOCK(p);
return (0);
}
+ if (SIGISMEMBER(p->p_sigacts->ps_sigignore, sig) ||
+ SIGISMEMBER(td->td_sigmask, sig)) {
+ /* Only allow them in write()/ioctl(). */
+ PROC_UNLOCK(p);
+ return (sig == SIGTTOU ? 0 : EIO);
+ }
+
+ pg = p->p_pgrp;
+ if (p->p_flag & P_PPWAIT || pg->pg_jobc == 0) {
+ /* Don't allow the action to happen. */
+ PROC_UNLOCK(p);
+ return (EIO);
+ }
+ PROC_UNLOCK(p);
+
/*
* Send the signal and sleep until we're the new
* foreground process group.
*/
- pg = p->p_pgrp;
- PROC_UNLOCK(p);
- if (pg->pg_jobc == 0)
- return (EIO);
PGRP_LOCK(pg);
pgsignal(pg, sig, 1);
PGRP_UNLOCK(pg);
More information about the svn-src-all
mailing list