[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

control ttys again



hello

 yes dosmem.c again...  and set_auxhandle (Bconmap) did not ++tty->use_cnt
wich was another reason for zeroed tty pgroups.

 now if the modem devices could turn off local mode and send signals
immediately... :)

 cheers
	Juergen

Index: dosmem.c
@@ -748,6 +748,7 @@
 		}
 	}
 
+#if 0
 /* release the controlling terminal, if we're a process group leader */
 	fp = curproc->handle[-1];
 	if (fp && is_terminal(fp) && curproc->pgrp == curproc->pid) {
@@ -755,6 +756,37 @@
 		if (curproc->pgrp == tty->pgrp)
 			tty->pgrp = 0;
 	}
+#else
+/* release the controlling terminal, if we're the last member of this pgroup */
+	fp = curproc->control;
+	if (fp && is_terminal(fp)) {
+		struct tty *tty = (struct tty *)fp->devinfo;
+		int pgrp = curproc->pgrp;
+
+		if (pgrp == tty->pgrp) {
+			PROC *p;
+			FILEPTR *pfp;
+
+			if (tty->use_cnt > 1) {
+				for (p = proclist; p; p = p->gl_next) {
+					if (p->pgrp == pgrp && p != curproc &&
+					    ((pfp = p->control)) &&
+					    pfp->fc.index == fp->fc.index &&
+					    pfp->fc.dev == fp->fc.dev)
+						goto found;
+				}
+			} else {
+				for (p = proclist; p; p = p->gl_next) {
+					if (p->pgrp == pgrp && p != curproc &&
+					    p->control == fp)
+						goto found;
+				}
+			}
+			tty->pgrp = 0;
+		}
+found:
+	}
+#endif
 
 /* close all files */
 	for (i = MIN_HANDLE; i < MAX_OPEN; i++) {
Index: biosfs.c
@@ -1885,6 +1885,7 @@
 
 	f = new_fileptr();
 	if (f) {
+		struct tty *tty;
 		f->links = 1;
 		f->flags = O_RDWR;
 		f->pos = 0;
@@ -1900,6 +1901,16 @@
 				f->dev = b->device;
 				if (b->device != &fakedev)
 					f->devinfo = (long)b->tty;
+#if 1
+/* don't close and reopen the same device again
+ */
+				if (p->aux && p->aux->fc.fs == &bios_filesys &&
+				    p->aux->fc.index == f->fc.index) {
+					f->links = 0;
+					dispose_fileptr(f);
+					return 1;
+				}
+#endif
 				goto found_device;
 			}
 		}
@@ -1911,6 +1922,16 @@
 			dispose_fileptr(f);
 			return 0;
 		}
+/* special code for opening a tty */
+		if ((tty = (struct tty *)f->devinfo)) {
+			extern struct tty default_tty;	/* in tty.c */
+
+			/* first open for this device? */
+			if (tty->use_cnt == 0) {
+				*tty = default_tty;
+			}
+			tty->use_cnt++;
+		}
 	} else {
 /* no memory! use the fake FILEPTR we
  * set up in biosfs_init
-- 
J"urgen Lock / nox@jelal.north.de / UUCP: ..!uunet!unido!uniol!jelal!nox
								...ohne Gewehr
PGP public key fingerprint =  8A 18 58 54 03 7B FC 12  1F 8B 63 C7 19 27 CF DA