aboutsummaryrefslogtreecommitdiff
path: root/sys/ki/kclcpr.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/ki/kclcpr.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'sys/ki/kclcpr.x')
-rw-r--r--sys/ki/kclcpr.x50
1 files changed, 50 insertions, 0 deletions
diff --git a/sys/ki/kclcpr.x b/sys/ki/kclcpr.x
new file mode 100644
index 00000000..b3822c63
--- /dev/null
+++ b/sys/ki/kclcpr.x
@@ -0,0 +1,50 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include <config.h>
+include "ki.h"
+
+# KCLCPR -- Close a connected subprocess.
+
+procedure kclcpr (pid, exit_status)
+
+int pid # channel descriptor
+int exit_status # exit status of the job
+
+int server, inchan, outchan
+int ki_sendrcv()
+include "kichan.com"
+include "kii.com"
+
+begin
+ # Possible if an abort occurs during the open.
+ if (pid <= 0) {
+ exit_status = OK
+ return
+ }
+
+ server = k_node[pid]
+
+ if (server == NULL) {
+ call zclcpr (k_oschan[pid], exit_status)
+ } else {
+ p_arg[1] = k_oschan[pid]
+ p_sbuflen = 0
+
+ if (ki_sendrcv (server, KI_ZCLCPR, 0) == ERR)
+ exit_status = ERR
+ else
+ exit_status = p_arg[1]
+ }
+
+ # The channel descriptor numbers of the two cds used for the i/o
+ # streams are encoded in the k_status field of the PID cd.
+
+ inchan = k_status[pid] / MAX_CHANNELS
+ outchan = mod (k_status[pid], MAX_CHANNELS)
+
+ # Free the 3 channel descriptors used by the subprocess.
+ call ki_freechan (pid)
+ call ki_freechan (inchan)
+ call ki_freechan (outchan)
+end