aboutsummaryrefslogtreecommitdiff
path: root/sys/etc/prupdate.x
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /sys/etc/prupdate.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/etc/prupdate.x')
-rw-r--r--sys/etc/prupdate.x61
1 files changed, 61 insertions, 0 deletions
diff --git a/sys/etc/prupdate.x b/sys/etc/prupdate.x
new file mode 100644
index 00000000..49aa7e56
--- /dev/null
+++ b/sys/etc/prupdate.x
@@ -0,0 +1,61 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <error.h>
+include <config.h>
+include <prstat.h>
+
+# PRUPDATE -- Broadcast a message to a process, or if pid=0, to all connected
+# subprocesses. Used primarily to incrementally pass SET and CHDIR commands to
+# subprocesses, eliminating the need to reconnect each process. Note that the
+# child process does not return "bye" in response to one of the builtin
+# functions SET and CHDIR. NOTE: if a child process is marked "busy" the
+# message is not sent to that process; only idle processes receive the message.
+
+procedure prupdate (pid, message, flushout)
+
+int pid #I process to be updated, or 0 for all procs
+char message[ARB] #I message to be broadcast to each child
+int flushout #I flush output
+
+int pr, status
+pointer sp, cmd, op
+int gstrcpy(), prstati()
+include "prc.com"
+
+begin
+ call smark (sp)
+ call salloc (cmd, SZ_COMMAND, TY_CHAR)
+
+ # Make sure that the message string is non-null and is newline
+ # delimited.
+
+ op = cmd + gstrcpy (message, Memc[cmd], SZ_COMMAND)
+ if (op == cmd) {
+ call sfree (sp)
+ return
+ } else if (Memc[op-1] != '\n') {
+ Memc[op] = '\n'
+ Memc[op+1] = EOS
+ }
+
+ # Broadcast the message. If the child fails to process the command
+ # and returns the ERROR statement, the error will not be detected until
+ # the next user command is sent to the process (and indeed may corrupt
+ # the protocol). The parent should execute the SET or CHDIR prior
+ # to sending it to the child to make sure it is valid.
+
+ for (pr=1; pr <= MAX_CHILDPROCS; pr=pr+1)
+ if ((pid != NULL && pr_pid[pr] == pid) ||
+ (pid == NULL && pr_pid[pr] != NULL)) {
+
+ status = prstati (pr_pid[pr], PR_STATUS)
+ if (status == P_RUNNING) {
+ iferr (call putline (pr_outfd[pr], Memc[cmd]))
+ call erract (EA_WARN)
+ else if (flushout == YES)
+ call flush (pr_outfd[pr])
+ }
+ }
+
+ call sfree (sp)
+end