summaryrefslogtreecommitdiff
path: root/sys/kern/tty_pty.c
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>1995-10-25 18:23:58 +0000
committerBruce Evans <bde@FreeBSD.org>1995-10-25 18:23:58 +0000
commite2f15ca546687c8c5caa3ce66e48b2222a48f03b (patch)
tree9660e224f20962207b63b874825983163ba4ddb5 /sys/kern/tty_pty.c
parent12bc45a8df7c7590c1426b97d2da2aef6ed683f3 (diff)
Notes
Diffstat (limited to 'sys/kern/tty_pty.c')
-rw-r--r--sys/kern/tty_pty.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c
index da4449aa8699..544d8a59d2ea 100644
--- a/sys/kern/tty_pty.c
+++ b/sys/kern/tty_pty.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tty_pty.c 8.2 (Berkeley) 9/23/93
- * $Id: tty_pty.c,v 1.20 1995/09/08 11:08:38 bde Exp $
+ * $Id: tty_pty.c,v 1.21 1995/09/19 12:26:47 bde Exp $
*/
/*
@@ -52,6 +52,10 @@
#include <sys/vnode.h>
#include <sys/signalvar.h>
+void ptyattach __P((int n));
+void ptsstart __P((struct tty *tp));
+void ptcwakeup __P((struct tty *tp, int flag));
+
#if NPTY == 1
#undef NPTY
#define NPTY 32 /* crude XXX */
@@ -486,7 +490,8 @@ again:
if (pti->pt_flags & PF_REMOTE) {
if (tp->t_canq.c_cc)
goto block;
- while (uio->uio_resid > 0 && tp->t_canq.c_cc < TTYHOG - 1) {
+ while ((uio->uio_resid > 0 || cc > 0) &&
+ tp->t_canq.c_cc < TTYHOG - 1) {
if (cc == 0) {
cc = min(uio->uio_resid, BUFSIZ);
cc = min(cc, TTYHOG - 1 - tp->t_canq.c_cc);
@@ -495,19 +500,23 @@ again:
if (error)
return (error);
/* check again for safety */
- if ((tp->t_state&TS_ISOPEN) == 0)
+ if ((tp->t_state & TS_ISOPEN) == 0) {
+ /* adjust as usual */
+ uio->uio_resid += cc;
return (EIO);
+ }
}
if (cc)
- (void) b_to_q((char *)cp, cc, &tp->t_canq);
- cc = 0;
+ cc -= b_to_q((char *)cp, cc, &tp->t_canq);
}
+ /* adjust for data copied in but not written */
+ uio->uio_resid += cc;
(void) putc(0, &tp->t_canq);
ttwakeup(tp);
wakeup(TSA_PTS_READ(tp));
return (0);
}
- while (uio->uio_resid > 0) {
+ while (uio->uio_resid > 0 || cc > 0) {
if (cc == 0) {
cc = min(uio->uio_resid, BUFSIZ);
cp = locbuf;
@@ -515,8 +524,11 @@ again:
if (error)
return (error);
/* check again for safety */
- if ((tp->t_state&TS_ISOPEN) == 0)
+ if ((tp->t_state & TS_ISOPEN) == 0) {
+ /* adjust for data copied in but not written */
+ uio->uio_resid += cc;
return (EIO);
+ }
}
while (cc > 0) {
if ((tp->t_rawq.c_cc + tp->t_canq.c_cc) >= TTYHOG - 2 &&
@@ -536,8 +548,11 @@ block:
* Come here to wait for slave to open, for space
* in outq, or space in rawq.
*/
- if ((tp->t_state & TS_CONNECTED) == 0)
+ if ((tp->t_state & TS_CONNECTED) == 0) {
+ /* adjust for data copied in but not written */
+ uio->uio_resid += cc;
return (EIO);
+ }
if (flag & IO_NDELAY) {
/* adjust for data copied in but not written */
uio->uio_resid += cc;