annotate src/vmsproc.c @ 97:498bf5da1c90

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