annotate src/vmsproc.c @ 4026:7b72e141f1ad

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