From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- sys/ki/kopcpr.x | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 sys/ki/kopcpr.x (limited to 'sys/ki/kopcpr.x') diff --git a/sys/ki/kopcpr.x b/sys/ki/kopcpr.x new file mode 100644 index 00000000..21497992 --- /dev/null +++ b/sys/ki/kopcpr.x @@ -0,0 +1,47 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include +include +include "ki.h" + +# KOPCPR -- Open a connected subprocess. + +procedure kopcpr (process, inchan, outchan, pid) + +char process[ARB] # packed osfn of process executable +int inchan, outchan # receives process input output channels +int pid # receives process id + +int server +int ki_connect(), ki_sendrcv(), ki_getchan() +include "kichan.com" +include "kii.com" + +begin + server = ki_connect (process) + + if (server == NULL) { + call strpak (p_sbuf[p_arg[1]], p_sbuf, SZ_SBUF) + call zopcpr (p_sbuf, inchan, outchan, pid) + } else { + if (ki_sendrcv (server, KI_ZOPCPR, 0) == ERR) + pid = ERR + else { + pid = p_arg[1] + inchan = p_arg[2] + outchan = p_arg[3] + } + } + + # Allocate 3 channel descriptors, one for the each of the i/o + # channels and another for the PID. Save the channel descriptor + # numbers of the i/o channels in the status field of the PID + # descriptor to permit freeing the lot at disconnect time. + + if (pid != ERR) { + pid = ki_getchan (server, pid) + inchan = ki_getchan (server, inchan) + outchan = ki_getchan (server, outchan) + k_status[pid] = inchan * MAX_CHANNELS + outchan + } +end -- cgit