annotate src/vmsproc.c @ 11862:10a973a88e87

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