2011/3/11 Anton Maksimenkov <[email protected]>:
> If some process can catch COM port in a way that noone can use the
> port and noone can kill that process - it is wrong situation.

And here is the quick path which solves the problem:

--- /usr/origsrc/sys/kern/tty.c Mon Oct 11 22:20:15 2010
+++ /usr/src/sys/kern/tty.c     Fri Mar 11 16:24:35 2011
@@ -1189,6 +1189,7 @@
 ttywait(struct tty *tp)
 {
        int error, s;
+       struct proc *p = curproc;

        error = 0;
        s = spltty();
@@ -1200,8 +1201,11 @@
                    (ISSET(tp->t_state, TS_CARR_ON) || ISSET(tp->t_cflag, 
CLOCAL))
                    && tp->t_oproc) {
                        SET(tp->t_state, TS_ASLEEP);
-                       error = ttysleep(tp, &tp->t_outq, TTOPRI | PCATCH, 
ttyout, 0);
+                       error = ttysleep(tp, &tp->t_outq, TTOPRI | PCATCH, 
ttyout, 100);
                        if (error)
+                               break;
+                       /* If the process exiting we have to exit anyhow */
+                       if (p->p_flag & P_WEXIT)
                                break;
                } else
                        break;

I'm not so sure about tty's "corner cases" and about actual value of timeout.
Additionally, I think that tp->t_outq.c_cc may be checked periodically
to see if the tty still sending bytes or it is time to break it.

So, it would be best if someone check if there may be better place.
-- 
antonvm

Reply via email to