kernel: first pieces of job control logic
authorAlan Cox <alan@linux.intel.com>
Sun, 27 Dec 2015 13:06:49 +0000 (13:06 +0000)
committerAlan Cox <alan@linux.intel.com>
Sun, 27 Dec 2015 13:06:49 +0000 (13:06 +0000)
Kernel/include/kernel.h
Kernel/level2.c
Kernel/tty.c

index 54138ce..11b352e 100644 (file)
@@ -38,6 +38,11 @@ From UZI by Doug Braun and UZI280 by Stefan Nitschke.
 
 #ifdef CONFIG_LEVEL_2
 #include "level2.h"
+#else
+
+#define jobcontrol_in(x)
+#define jobcontrol_out(x)
+
 #endif
 
 #define CPM_EMULATOR_FILENAME    "/usr/cpm/emulator"
index 53bf780..b25a5fb 100644 (file)
@@ -11,3 +11,23 @@ int in_group(uint16_t gid)
                        return 1;
        return 0;
 }
+
+void jobcontrol_in(struct tty *t)
+{
+       if (udata.u_proc->p_pgrp == t->pgrp)
+               return;
+       ssig(udata.u_proc, SIGTTIN);
+       /* So we halt */
+       pause(0);
+}
+
+void jobcontrol_out(struct tty *t)
+{
+       if (udata.u_proc->p_pgrp == t->pgrp)
+               return;
+       if (!(t->termios.t_lflag & TOSTOP))
+               return;
+       ssig(udata.u_proc, SIGTTOU);
+       /* So we halt */
+       pause(0);
+}
index 87bc043..264c0c3 100644 (file)
@@ -50,6 +50,7 @@ int tty_read(uint8_t minor, uint8_t rawflag, uint8_t flag)
                                udata.u_error = ENXIO;
                                return -1;
                         }
+                        jobcontrol_in(t);
                        if (remq(q, &c)) {
                                if (udata.u_sysio)
                                        *udata.u_base = c;
@@ -114,8 +115,8 @@ int tty_write(uint8_t minor, uint8_t rawflag, uint8_t flag)
                                break;
                        if (psleep_flags_io(&t->flag, flag, &written))
                                return written;
+                        jobcontrol_out(t);
                }
-
                if (!(t->flag & TTYF_DISCARD)) {
                        if (udata.u_sysio)
                                c = *udata.u_base;
@@ -229,6 +230,7 @@ int tty_ioctl(uint8_t minor, uarg_t request, char *data)
                udata.u_error = ENXIO;
                return -1;
         }
+        jobcontrol_in(t);
        switch (request) {
        case TCGETS:
                return uput(&t->termios, data, sizeof(struct termios));