annotate src/vmsproc.c @ 26583:3251a6750150

(custom-declare-face): Purecopy DOC.
author Dave Love <fx@gnu.org>
date Wed, 24 Nov 1999 20:35:54 +0000
parents a5eaace0fa01
children 4b675266db04
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* Interfaces to subprocesses on VMS.
7307
cd81dba38a49 Update copyright.
Karl Heuer <kwzh@gnu.org>
parents: 6212
diff changeset
2 Copyright (C) 1988, 1994 Free Software Foundation, Inc.
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 This file is part of GNU Emacs.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
12244
ac7375e60931 Update GPL to version 2.
Karl Heuer <kwzh@gnu.org>
parents: 9323
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 any later version.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 GNU General Public License for more details.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
19 Boston, MA 02111-1307, USA. */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 Event flag and `select' emulation
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 0 is never used
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 1 is the terminal
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 23 is the timer event flag
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 24-31 are reserved by VMS
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 */
6212
7a86fbeb5c88 Include config.h, lisp.h, buffer.h, process.h, commands.h, errno.h and file.h.
Richard M. Stallman <rms@gnu.org>
parents: 5252
diff changeset
30 #include <config.h>
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 #include <ssdef.h>
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 #include <iodef.h>
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 #include <dvidef.h>
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 #include <clidef.h>
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 #include "vmsproc.h"
6212
7a86fbeb5c88 Include config.h, lisp.h, buffer.h, process.h, commands.h, errno.h and file.h.
Richard M. Stallman <rms@gnu.org>
parents: 5252
diff changeset
36 #include "lisp.h"
7a86fbeb5c88 Include config.h, lisp.h, buffer.h, process.h, commands.h, errno.h and file.h.
Richard M. Stallman <rms@gnu.org>
parents: 5252
diff changeset
37 #include "buffer.h"
7a86fbeb5c88 Include config.h, lisp.h, buffer.h, process.h, commands.h, errno.h and file.h.
Richard M. Stallman <rms@gnu.org>
parents: 5252
diff changeset
38 #include <file.h>
7a86fbeb5c88 Include config.h, lisp.h, buffer.h, process.h, commands.h, errno.h and file.h.
Richard M. Stallman <rms@gnu.org>
parents: 5252
diff changeset
39 #include "process.h"
7a86fbeb5c88 Include config.h, lisp.h, buffer.h, process.h, commands.h, errno.h and file.h.
Richard M. Stallman <rms@gnu.org>
parents: 5252
diff changeset
40 #include "commands.h"
7a86fbeb5c88 Include config.h, lisp.h, buffer.h, process.h, commands.h, errno.h and file.h.
Richard M. Stallman <rms@gnu.org>
parents: 5252
diff changeset
41 #include <errno.h>
7a86fbeb5c88 Include config.h, lisp.h, buffer.h, process.h, commands.h, errno.h and file.h.
Richard M. Stallman <rms@gnu.org>
parents: 5252
diff changeset
42 extern Lisp_Object call_process_cleanup ();
7a86fbeb5c88 Include config.h, lisp.h, buffer.h, process.h, commands.h, errno.h and file.h.
Richard M. Stallman <rms@gnu.org>
parents: 5252
diff changeset
43
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 #define KEYBOARD_EVENT_FLAG 1
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 #define TIMER_EVENT_FLAG 23
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 static VMS_PROC_STUFF procList[MAX_EVENT_FLAGS+1];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 get_kbd_event_flag ()
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 Return the first event flag for keyboard input.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 VMS_PROC_STUFF *vs = &procList[KEYBOARD_EVENT_FLAG];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 vs->busy = 1;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 vs->pid = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 return (vs->eventFlag);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 get_timer_event_flag ()
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 Return the last event flag for use by timeouts
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 VMS_PROC_STUFF *vs = &procList[TIMER_EVENT_FLAG];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 vs->busy = 1;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 vs->pid = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 return (vs->eventFlag);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 VMS_PROC_STUFF *
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 get_vms_process_stuff ()
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 Return a process_stuff structure
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 We use 1-23 as our event flags to simplify implementing
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 a VMS `select' call.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 int i;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 VMS_PROC_STUFF *vs;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 for (i=1, vs = procList; i<MAX_EVENT_FLAGS; i++, vs++)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 if (!vs->busy)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 vs->busy = 1;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 vs->inputChan = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 vs->pid = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 sys$clref (vs->eventFlag);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 return (vs);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 return ((VMS_PROC_STUFF *)0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 give_back_vms_process_stuff (vs)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 VMS_PROC_STUFF *vs;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 Return an event flag to our pool
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 vs->busy = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 vs->inputChan = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 vs->pid = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 VMS_PROC_STUFF *
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 get_vms_process_pointer (pid)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 int pid;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 Given a pid, return the VMS_STUFF pointer
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 int i;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 VMS_PROC_STUFF *vs;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 /* Don't search the last one */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 for (i=0, vs=procList; i<MAX_EVENT_FLAGS; i++, vs++)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 if (vs->busy && vs->pid == pid)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 return (vs);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 return ((VMS_PROC_STUFF *)0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 start_vms_process_read (vs)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 VMS_PROC_STUFF *vs;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 Start an asynchronous read on a VMS process
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 We will catch up with the output sooner or later
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 int status;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 int ProcAst ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 status = sys$qio (vs->eventFlag, vs->outputChan, IO$_READVBLK,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 vs->iosb, 0, vs,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 vs->inputBuffer, sizeof (vs->inputBuffer), 0, 0, 0, 0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 if (status != SS$_NORMAL)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 return (0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 return (1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 extern int waiting_for_ast; /* in sysdep.c */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 extern int timer_ef;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 extern int input_ef;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 select (nDesc, rdsc, wdsc, edsc, timeOut)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 int nDesc;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 int *rdsc;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 int *wdsc;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 int *edsc;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 int *timeOut;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 /* Emulate a select call
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 We know that we only use event flags 1-23
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 timeout == 100000 & bit 0 set means wait on keyboard input until
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 something shows up. If timeout == 0, we just read the event
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 flags and return what we find. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 int nfds = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 int status;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 int time[2];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 int delta = -10000000;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 int zero = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 int timeout = *timeOut;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 unsigned long mask, readMask, waitMask;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 if (rdsc)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 readMask = *rdsc << 1; /* Unix mask is shifted over 1 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 readMask = 0; /* Must be a wait call */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 sys$clref (KEYBOARD_EVENT_FLAG);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 sys$setast (0); /* Block interrupts */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 sys$readef (KEYBOARD_EVENT_FLAG, &mask); /* See what is set */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 mask &= readMask; /* Just examine what we need */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 if (mask == 0)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 { /* Nothing set, we must wait */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 if (timeout != 0)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 { /* Not just inspecting... */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 if (!(timeout == 100000 &&
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 readMask == (1 << KEYBOARD_EVENT_FLAG)))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 lib$emul (&timeout, &delta, &zero, time);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 sys$setimr (TIMER_EVENT_FLAG, time, 0, 1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 waitMask = readMask | (1 << TIMER_EVENT_FLAG);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 waitMask = readMask;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 if (waitMask & (1 << KEYBOARD_EVENT_FLAG))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 sys$clref (KEYBOARD_EVENT_FLAG);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 waiting_for_ast = 1; /* Only if reading from 0 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 sys$setast (1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 sys$wflor (KEYBOARD_EVENT_FLAG, waitMask);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 sys$cantim (1, 0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 sys$readef (KEYBOARD_EVENT_FLAG, &mask);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 if (readMask & (1 << KEYBOARD_EVENT_FLAG))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 waiting_for_ast = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 sys$setast (1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 Count number of descriptors that are ready
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 mask &= readMask;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 if (rdsc)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 *rdsc = (mask >> 1); /* Back to Unix format */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 for (nfds = 0; mask; mask >>= 1)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 if (mask & 1)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 nfds++;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 return (nfds);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 #define MAX_BUFF 1024
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 write_to_vms_process (vs, buf, len)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 VMS_PROC_STUFF *vs;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 char *buf;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 int len;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 Write something to a VMS process.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 We have to map newlines to carriage returns for VMS.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 char ourBuff[MAX_BUFF];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 short iosb[4];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 int status;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 int in, out;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 while (len > 0)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 out = map_nl_to_cr (buf, ourBuff, len, MAX_BUFF);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 status = sys$qiow (0, vs->inputChan, IO$_WRITEVBLK|IO$M_NOFORMAT,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 iosb, 0, 0, ourBuff, out, 0, 0, 0, 0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 if (status != SS$_NORMAL || (status = iosb[0]) != SS$_NORMAL)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 error ("Could not write to subprocess: %x", status);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 return (0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 }
6212
7a86fbeb5c88 Include config.h, lisp.h, buffer.h, process.h, commands.h, errno.h and file.h.
Richard M. Stallman <rms@gnu.org>
parents: 5252
diff changeset
254 len -= out;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 return (1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 static
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 map_nl_to_cr (in, out, maxIn, maxOut)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 char *in;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 char *out;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 int maxIn;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 int maxOut;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 Copy `in' to `out' remapping `\n' to `\r'
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 int c;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 int o;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 for (o=0; maxIn-- > 0 && o < maxOut; o++)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 c = *in++;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 *out++ = (c == '\n') ? '\r' : c;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 return (o);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 clean_vms_buffer (buf, len)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 char *buf;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 int len;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 Sanitize output from a VMS subprocess
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 Strip CR's and NULLs
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 char *oBuf = buf;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 char c;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 int l = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 while (len-- > 0)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 c = *buf++;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 if (c == '\r' || c == '\0')
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 ;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 *oBuf++ = c;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 l++;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 return (l);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 For the CMU PTY driver
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 #define PTYNAME "PYA0:"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 get_pty_channel (inDevName, outDevName, inChannel, outChannel)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 char *inDevName;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 char *outDevName;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 int *inChannel;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 int *outChannel;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 int PartnerUnitNumber;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 int status;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 struct {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 int l;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 char *a;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 } d;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 struct {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 short BufLen;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 short ItemCode;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 int *BufAddress;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 int *ItemLength;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 } g[2];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 d.l = strlen (PTYNAME);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 d.a = PTYNAME;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 *inChannel = 0; /* Should be `short' on VMS */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 *outChannel = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 *inDevName = *outDevName = '\0';
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 status = sys$assign (&d, inChannel, 0, 0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 if (status == SS$_NORMAL)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 *outChannel = *inChannel;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 g[0].BufLen = sizeof (PartnerUnitNumber);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 g[0].ItemCode = DVI$_UNIT;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 g[0].BufAddress = &PartnerUnitNumber;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 g[0].ItemLength = (int *)0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 g[1].BufLen = g[1].ItemCode = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 status = sys$getdviw (0, *inChannel, 0, &g, 0, 0, 0, 0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 if (status == SS$_NORMAL)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 sprintf (inDevName, "_TPA%d:", PartnerUnitNumber);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 strcpy (outDevName, inDevName);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 return (status);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 VMSgetwd (buf)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 char *buf;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 Return the current directory
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 char curdir[256];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 char *getenv ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 char *s;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 short len;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 int status;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 struct
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 int l;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 char *a;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 } d;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 s = getenv ("SYS$DISK");
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 if (s)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 strcpy (buf, s);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 *buf = '\0';
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 d.l = 255;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 d.a = curdir;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 status = sys$setddir (0, &len, &d);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 if (status & 1)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 curdir[len] = '\0';
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 strcat (buf, curdir);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 static
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 call_process_ast (vs)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 VMS_PROC_STUFF *vs;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391 sys$setef (vs->eventFlag);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 void
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 child_setup (in, out, err, new_argv, env)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 int in, out, err;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 register char **new_argv;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 char **env;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 /* ??? I suspect that maybe this shouldn't be done on VMS. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 #ifdef subprocesses
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 /* Close Emacs's descriptors that this process should not have. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 close_process_descs ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405
9106
40a353de483c (child_setup, Fcall_process): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 7307
diff changeset
406 if (STRINGP (current_buffer->directory))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 chdir (XSTRING (current_buffer->directory)->data);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 DEFUN ("call-process", Fcall_process, Scall_process, 1, MANY, 0,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 "Call PROGRAM synchronously in a separate process.\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 Program's input comes from file INFILE (nil means null device, `NLA0:').\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 Insert output in BUFFER before point; t means current buffer;\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414 nil for BUFFER means discard it; 0 means discard and don't wait.\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted.\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 Remaining arguments are strings passed as command arguments to PROGRAM.\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 This function waits for PROGRAM to terminate, unless BUFFER is 0;\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 if you quit, the process is killed.")
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 (nargs, args)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 int nargs;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421 register Lisp_Object *args;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 Lisp_Object display, buffer, path;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 char oldDir[512];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 int inchannel, outchannel;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 int len;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 int call_process_ast ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 struct
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 int l;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 char *a;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 } dcmd, din, dout;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 char inDevName[65];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 char outDevName[65];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 short iosb[4];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 int status;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 int SpawnFlags = CLI$M_NOWAIT;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 VMS_PROC_STUFF *vs;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 VMS_PROC_STUFF *get_vms_process_stuff ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 int fd[2];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 int filefd;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 register int pid;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 char buf[1024];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 int count = specpdl_ptr - specpdl;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 register unsigned char **new_argv;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 struct buffer *old = current_buffer;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 CHECK_STRING (args[0], 0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 152
diff changeset
450 if (nargs <= 1 || NILP (args[1]))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 args[1] = build_string ("NLA0:");
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 args[1] = Fexpand_file_name (args[1], current_buffer->directory);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 CHECK_STRING (args[1], 1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 register Lisp_Object tem;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 buffer = tem = args[2];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460 if (nargs <= 2)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 buffer = Qnil;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462 else if (!(EQ (tem, Qnil) || EQ (tem, Qt)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 || XFASTINT (tem) == 0))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465 buffer = Fget_buffer (tem);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 CHECK_BUFFER (buffer, 2);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470 display = nargs >= 3 ? args[3] : Qnil;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 if (args[0] == "*dcl*" then we need to skip pas the "-c",
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 else args[0] is the program to run.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 register int i;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478 int arg0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479 int firstArg;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
480
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
481 if (strcmp (XSTRING (args[0])->data, "*dcl*") == 0)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
482 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483 arg0 = 5;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 firstArg = 6;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488 arg0 = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489 firstArg = 4;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491 len = XSTRING (args[arg0])->size + 1;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492 for (i = firstArg; i < nargs; i++)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 CHECK_STRING (args[i], i);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
495 len += XSTRING (args[i])->size + 1;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
497 new_argv = alloca (len);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498 strcpy (new_argv, XSTRING (args[arg0])->data);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
499 for (i = firstArg; i < nargs; i++)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501 strcat (new_argv, " ");
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502 strcat (new_argv, XSTRING (args[i])->data);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
504 dcmd.l = len-1;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505 dcmd.a = new_argv;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
506
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507 status = get_pty_channel (inDevName, outDevName, &inchannel, &outchannel);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 if (!(status & 1))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509 error ("Error getting PTY channel: %x", status);
9106
40a353de483c (child_setup, Fcall_process): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 7307
diff changeset
510 if (INTEGERP (buffer))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
512 dout.l = strlen ("NLA0:");
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
513 dout.a = "NLA0:";
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
514 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 dout.l = strlen (outDevName);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518 dout.a = outDevName;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
519 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
520
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521 vs = get_vms_process_stuff ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522 if (!vs)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
524 sys$dassgn (inchannel);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
525 sys$dassgn (outchannel);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
526 error ("Too many VMS processes");
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
527 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
528 vs->inputChan = inchannel;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
529 vs->outputChan = outchannel;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
530 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
531
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
532 filefd = open (XSTRING (args[1])->data, O_RDONLY, 0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
533 if (filefd < 0)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
534 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
535 sys$dassgn (inchannel);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
536 sys$dassgn (outchannel);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
537 give_back_vms_process_stuff (vs);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
538 report_file_error ("Opening process input file", Fcons (args[1], Qnil));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
539 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
540 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
541 close (filefd);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
542
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
543 din.l = XSTRING (args[1])->size;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
544 din.a = XSTRING (args[1])->data;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
545
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
546 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
547 Start a read on the process channel
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
548 */
9106
40a353de483c (child_setup, Fcall_process): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 7307
diff changeset
549 if (!INTEGERP (buffer))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
550 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
551 start_vms_process_read (vs);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
552 SpawnFlags = CLI$M_NOWAIT;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
553 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
554 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
555 SpawnFlags = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
556
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
558 On VMS we need to change the current directory
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
559 of the parent process before forking so that
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
560 the child inherit that directory. We remember
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561 where we were before changing.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
563 VMSgetwd (oldDir);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564 child_setup (0, 0, 0, 0, 0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
565 status = lib$spawn (&dcmd, &din, &dout, &SpawnFlags, 0, &vs->pid,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
566 &vs->exitStatus, 0, call_process_ast, vs);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
567 chdir (oldDir);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
568
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
569 if (status != SS$_NORMAL)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
570 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
571 sys$dassgn (inchannel);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
572 sys$dassgn (outchannel);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
573 give_back_vms_process_stuff (vs);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
574 error ("Error calling LIB$SPAWN: %x", status);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
575 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
576 pid = vs->pid;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
577
9106
40a353de483c (child_setup, Fcall_process): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 7307
diff changeset
578 if (INTEGERP (buffer))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
579 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
580 #ifndef subprocesses
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
581 wait_without_blocking ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
582 #endif subprocesses
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
583 return Qnil;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
584 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
585
5252
3c213dd261d8 (Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents: 484
diff changeset
586 if (!NILP (display) && INTERACTIVE)
3c213dd261d8 (Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents: 484
diff changeset
587 prepare_menu_bars ();
3c213dd261d8 (Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents: 484
diff changeset
588
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
589 record_unwind_protect (call_process_cleanup,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
590 Fcons (make_number (fd[0]), make_number (pid)));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
591
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
592
9106
40a353de483c (child_setup, Fcall_process): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 7307
diff changeset
593 if (BUFFERP (buffer))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
594 Fset_buffer (buffer);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
596 immediate_quit = 1;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
597 QUIT;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599 while (1)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
600 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
601 sys$waitfr (vs->eventFlag);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602 if (vs->iosb[0] & 1)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
603 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
604 immediate_quit = 0;
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 152
diff changeset
605 if (!NILP (buffer))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
606 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
607 vs->iosb[1] = clean_vms_buffer (vs->inputBuffer, vs->iosb[1]);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
608 InsCStr (vs->inputBuffer, vs->iosb[1]);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
609 }
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 152
diff changeset
610 if (!NILP (display) && INTERACTIVE)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
611 redisplay_preserve_echo_area ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
612 immediate_quit = 1;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
613 QUIT;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
614 if (!start_vms_process_read (vs))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
615 break; /* The other side went away */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
616 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
617 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
618 break;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
619 }
5252
3c213dd261d8 (Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents: 484
diff changeset
620
3c213dd261d8 (Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents: 484
diff changeset
621 sys$dassgn (inchannel);
3c213dd261d8 (Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents: 484
diff changeset
622 sys$dassgn (outchannel);
3c213dd261d8 (Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents: 484
diff changeset
623 give_back_vms_process_stuff (vs);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
624
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
625 /* Wait for it to terminate, unless it already has. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
626 wait_for_termination (pid);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
627
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
628 immediate_quit = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
629
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
630 set_current_buffer (old);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
631
152
50e816f7e0a5 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 118
diff changeset
632 return unbind_to (count, Qnil);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
633 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
634
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
635 create_process (process, new_argv)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636 Lisp_Object process;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637 char *new_argv;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
638 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
639 int pid, inchannel, outchannel, forkin, forkout;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
640 char old_dir[512];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
641 char in_dev_name[65];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
642 char out_dev_name[65];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
643 short iosb[4];
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 int status;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
645 int spawn_flags = CLI$M_NOWAIT;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
646 int child_sig ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
647 struct {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
648 int l;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
649 char *a;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
650 } din, dout, dprompt, dcmd;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
651 VMS_PROC_STUFF *vs;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
652 VMS_PROC_STUFF *get_vms_process_stuff ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
653
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654 status = get_pty_channel (in_dev_name, out_dev_name, &inchannel, &outchannel);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655 if (!(status & 1))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
656 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
657 remove_process (process);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
658 error ("Error getting PTY channel: %x", status);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
659 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
660 dout.l = strlen (out_dev_name);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
661 dout.a = out_dev_name;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662 dprompt.l = strlen (DCL_PROMPT);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
663 dprompt.a = DCL_PROMPT;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
664
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
665 if (strcmp (new_argv, "*dcl*") == 0)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
666 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
667 din.l = strlen (in_dev_name);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
668 din.a = in_dev_name;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
669 dcmd.l = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
670 dcmd.a = (char *)0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
671 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
672 else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
673 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 din.l = strlen ("NLA0:");
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675 din.a = "NLA0:";
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
676 dcmd.l = strlen (new_argv);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
677 dcmd.a = new_argv;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
678 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
679
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
680 /* Delay interrupts until we have a chance to store
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
681 the new fork's pid in its process structure */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
682 sys$setast (0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
683
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
684 vs = get_vms_process_stuff ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
685 if (vs == 0)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
686 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
687 sys$setast (1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
688 remove_process (process);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
689 error ("Too many VMS processes");
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
690 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
691 vs->inputChan = inchannel;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
692 vs->outputChan = outchannel;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
693
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
694 /* Start a read on the process channel */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
695 start_vms_process_read (vs);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
696
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
697 /* Switch current directory so that the child inherits it. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
698 VMSgetwd (old_dir);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
699 child_setup (0, 0, 0, 0, 0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
700
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
701 status = lib$spawn (&dcmd, &din, &dout, &spawn_flags, 0, &vs->pid,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
702 &vs->exitStatus, 0, child_sig, vs, &dprompt);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
703 chdir (old_dir);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
704
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
705 if (status != SS$_NORMAL)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
706 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
707 sys$setast (1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
708 remove_process (process);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
709 error ("Error calling LIB$SPAWN: %x", status);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
710 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
711 vs->pid &= 0xffff; /* It needs to fit in a FASTINT,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
712 we don't need the rest of the bits */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
713 pid = vs->pid;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
714
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
715 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
716 ON VMS process->infd holds the (event flag-1)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
717 that we use for doing I/O on that process.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
718 `input_wait_mask' is the cluster of event flags
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
719 we can wait on.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
720
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
721 Event flags returned start at 1 for the keyboard.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
722 Since Unix expects descriptor 0 for the keyboard,
14036
621a575db6f7 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 12244
diff changeset
723 we subtract one from the event flag.
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
724 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
725 inchannel = vs->eventFlag-1;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
726
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
727 /* Record this as an active process, with its channels.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
728 As a result, child_setup will close Emacs's side of the pipes. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
729 chan_process[inchannel] = process;
9323
d428ab51a1bc (create_process): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents: 9106
diff changeset
730 XSETFASTINT (XPROCESS (process)->infd, inchannel);
d428ab51a1bc (create_process): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents: 9106
diff changeset
731 XSETFASTINT (XPROCESS (process)->outfd, outchannel);
6212
7a86fbeb5c88 Include config.h, lisp.h, buffer.h, process.h, commands.h, errno.h and file.h.
Richard M. Stallman <rms@gnu.org>
parents: 5252
diff changeset
732 XPROCESS (process)->status = Qrun
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
733
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
734 /* Delay interrupts until we have a chance to store
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
735 the new fork's pid in its process structure */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
736
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
737 #define NO_ECHO "set term/noecho\r"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
738 sys$setast (0);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
739 /*
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
740 Send a command to the process to not echo input
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
741
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
742 The CMU PTY driver does not support SETMODEs.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
743 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
744 write_to_vms_process (vs, NO_ECHO, strlen (NO_ECHO));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
745
9323
d428ab51a1bc (create_process): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents: 9106
diff changeset
746 XSETFASTINT (XPROCESS (process)->pid, pid);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
747 sys$setast (1);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
748 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
749
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
750 child_sig (vs)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
751 VMS_PROC_STUFF *vs;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
752 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
753 register int pid;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
754 Lisp_Object tail, proc;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
755 register struct Lisp_Process *p;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
756 int old_errno = errno;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
757
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
758 pid = vs->pid;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
759 sys$setef (vs->eventFlag);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
760
25663
a5eaace0fa01 Use XCAR and XCDR instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 14186
diff changeset
761 for (tail = Vprocess_alist; XSYMBOL (tail) != XSYMBOL (Qnil); tail = XCDR (tail))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
762 {
25663
a5eaace0fa01 Use XCAR and XCDR instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 14186
diff changeset
763 proc = XCDR (XCAR (tail));
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
764 p = XPROCESS (proc);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
765 if (EQ (p->childp, Qt) && XFASTINT (p->pid) == pid)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
766 break;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
767 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
768
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
769 if (XSYMBOL (tail) == XSYMBOL (Qnil))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
770 return;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
771
6212
7a86fbeb5c88 Include config.h, lisp.h, buffer.h, process.h, commands.h, errno.h and file.h.
Richard M. Stallman <rms@gnu.org>
parents: 5252
diff changeset
772 p->status = Fcons (Qexit, Fcons (make_number (vs->exitStatus), Qnil))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
773 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
774
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
775 syms_of_vmsproc ()
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
776 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
777 defsubr (&Scall_process);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
778 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
779
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
780 init_vmsproc ()
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
781 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
782 char *malloc ();
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
783 int i;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
784 VMS_PROC_STUFF *vs;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
785
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
786 for (vs=procList, i=0; i<MAX_EVENT_FLAGS+1; i++, vs++)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
787 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
788 vs->busy = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
789 vs->eventFlag = i;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
790 sys$clref (i);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
791 vs->inputChan = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
792 vs->pid = 0;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
793 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
794 procList[0].busy = 1; /* Zero is reserved */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
795 }