diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /sys/gio/cursor/gtrdiscon.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/gio/cursor/gtrdiscon.x')
-rw-r--r-- | sys/gio/cursor/gtrdiscon.x | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/sys/gio/cursor/gtrdiscon.x b/sys/gio/cursor/gtrdiscon.x new file mode 100644 index 00000000..5eba23f4 --- /dev/null +++ b/sys/gio/cursor/gtrdiscon.x @@ -0,0 +1,66 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include <gio.h> + +# GTR_DISCONNECT -- Disconnect from a kernel subprocess. To achieve an orderly +# shutdown we process any outstanding XMIT or XFER requests, then transmit an +# end of file (zero length record) to the kernel task when it reads from the +# graphics stream. The kernel should then shutdown and eventually we will +# receive "bye" from the process. We then call PRCLOSE to shutdown the +# process for good. Note: we do not expect anything but an XFER (read) request +# on the graphics stream, but it seems prudent to do something reasonable if +# some other request is received. + +procedure gtr_disconnect (pid, in, out, stream) + +int pid # process id of subprocess +int in, out # command i/o streams of the subprocess +int stream # graphics stream used by kernel + +pointer sp, sp2, lbuf, buf +int pseudofile, nchars, junk +bool streq() +int getline(), read(), strncmp(), psio_isxmit(), prclose(), pr_findproc() +errchk getline, prclose, read, write + +begin + call smark (sp) + call salloc (lbuf, SZ_LINE, TY_CHAR) + + while (getline (in, Memc[lbuf]) != EOF) { + if (streq (Memc[lbuf], "bye\n") || + strncmp (Memc[lbuf], "ERROR", 5) == 0) { + + junk = prclose (pid) + break + + } else if (Memc[lbuf] == '!') { + # OS escape. + call proscmd (pr_findproc(pid), Memc[lbuf+1]) + + } else { + call smark (sp2) + + switch (psio_isxmit (Memc[lbuf], pseudofile, nchars)) { + case XMIT: + call salloc (buf, nchars, TY_CHAR) + nchars = read (in, Memc[buf], nchars) + if (nchars > 0) + if (pseudofile == STDOUT || pseudofile == STDERR) + call write (pseudofile, Memc[buf], nchars) + + case XFER: + call salloc (buf, nchars, TY_CHAR) + if (pseudofile == STDIN) + nchars = read (pseudofile, Memc[buf], nchars) + else + nchars = 0 # this is the EOF + call psio_xfer (out, Memc[buf], nchars) + } + + call sfree (sp2) + } + } + + call sfree (sp) +end |