summaryrefslogtreecommitdiff
path: root/parallel/glunix/patches/patch-am
blob: d5968e4f4bfbcbf8f2d4fe9a992b0b697fb1a8dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
$NetBSD: patch-am,v 1.1.1.1 1998/10/21 19:59:30 garbled Exp $

--- glunix/src/rexec/drexec.cc.orig	Thu Oct  2 12:34:05 1997
+++ glunix/src/rexec/drexec.cc	Fri Apr  3 16:58:09 1998
@@ -308,3 +308,10 @@
 #include <stdlib.h>
+
+#ifdef __NetBSD__
+#include <sys/ptrace.h>
+#include <sys/ioctl.h>
+#else
 #include <stropts.h>
+#endif
+
 #include <grp.h>
@@ -355,5 +362,7 @@
 static int PtyMasterOpen(char *ptyName);
-/*static int PtySlaveOpen(char *ptyName, int uid, int gid);*/
+#ifdef __NetBSD__
+static int PtySlaveOpen(char *ptyName, int uid, int gid);
+#else
 static int PtySlaveOpen(char *ptyName, int ptyMasterFd);
-
+#endif
 /*****************************************************************************/
@@ -1143,4 +1152,8 @@
     // Open the stderr pty
+#ifdef __NetBSD__
+    if((ptyErrorSlaveFd = PtySlaveOpen(ptyErrorName, msg->uid, msg->gid)) == -1) {
+#else
     if((ptyErrorSlaveFd = PtySlaveOpen(ptyErrorName, ptyErrorMasterFd))
        == -1) {
+#endif
 	DE("PtySlaveOpen() failed\n");
@@ -1150,13 +1163,17 @@
 
-/*    if(setsid() == -1) {
-	Debug_Print(MODULE_REXEC, DEBUG_ERROR, "(rexec)ChildPtyPiping: "
-		    "setsid() failed\n");
-	return False;
-    }*/
+#ifdef __NetBSD__
+    if(setsid() == -1) {
+      DE("(rexec)ChildPtyPiping: setsid() failed\n");
+      return False;
+    }
+#endif
 
-    setpgrp();
+    setpgrp(0,0);
 
     // Open the stdin/stdout pty
+#ifdef __NetBSD__
+    if((ptySlaveFd = PtySlaveOpen(ptyName, msg->uid, msg->gid)) == -1) {
+#else
     if((ptySlaveFd = PtySlaveOpen(ptyName, ptyMasterFd)) == -1) {
-/*    if((ptySlaveFd = PtySlaveOpen(ptyName, msg->uid, msg->gid)) == -1) {*/
+#endif
 	DE("PtySlaveOpen() failed\n");
@@ -1166,22 +1183,21 @@
 
-/* This should work on BSD, but doesn't on SysV
-#if defined(TIOCSCTTY) && !defined(CIBAUD)
+#ifdef __NetBSD__
+    /* This should work on BSD, but doesn't on SysV*/
     if(ioctl(ptySlaveFd, TIOCSCTTY, (char *) 0) == -1) {
-	DE("cannot set controlling tty: %s\n", strerror(errno));
-	return False;
+      DE("cannot set controlling tty: %s\n", strerror(errno));
+      return False;
     }
-#else
-#error Nope
-#endif */
-
+#else 
     (void) ioctl(ptySlaveFd, TCSETSF, (char *)&startupTermios);
     (void) ioctl(ptySlaveFd, TIOCSWINSZ, (char *)&windowSize);
+#endif
 
-/*    while(tcsetattr(ptySlaveFd, TCSANOW, &startupTermios) == -1) {
-	if(errno == EINTR) {
-	    continue;
-	} else {
-	    * BUGBUG maybe should return failure here? *
-	    DE("ioctl: %s\n", strerror(errno));
-	}
+#ifdef __NetBSD__
+    while(tcsetattr(ptySlaveFd, TCSANOW, &startupTermios) == -1) {
+      if(errno == EINTR) {
+	continue;
+      } else {
+	/* BUGBUG maybe should return failure here? */
+	DE("ioctl: %s\n", strerror(errno));
+      }
     }
@@ -1189,16 +1205,18 @@
     if(ioctl(ptySlaveFd, TIOCSWINSZ, (char *) &windowSize) == -1) {
-	* BUGBUG maybe should return failure here? *
-	DE("ioctl: %s\n", strerror(errno));
-    }	*/
-    
+      /* BUGBUG maybe should return failure here? */
+	    DE("ioctl: %s\n", strerror(errno));
+    }  
+#else
     (void) ioctl(ptyErrorSlaveFd, TCSETSF, (char *)&startupTermios);
     (void) ioctl(ptyErrorSlaveFd, TIOCSWINSZ, (char *)&windowSize);
+#endif
 
-/*    while(tcsetattr(ptyErrorSlaveFd, TCSANOW, &startupTermios) == -1) {
-	if(errno == EINTR) {
-	    continue;
-	} else {
-	    * BUGBUG maybe should return failure here? *
-	    DE("ioctl: %s\n", strerror(errno));
-	}
+#ifdef __NetBSD__
+    while(tcsetattr(ptyErrorSlaveFd, TCSANOW, &startupTermios) == -1) {
+      if(errno == EINTR) {
+	continue;
+      } else {
+	/* BUGBUG maybe should return failure here? */
+	DE("ioctl: %s\n", strerror(errno));
+      }
     }
@@ -1206,5 +1224,6 @@
     if(ioctl(ptyErrorSlaveFd, TIOCSWINSZ, (char *) &windowSize) == -1) {
-	* BUGBUG maybe should return failure here? *
-	DE("ioctl: %s\n", strerror(errno));
-    }	*/
+      /* BUGBUG maybe should return failure here? */
+      DE("ioctl: %s\n", strerror(errno));
+    }
+#endif
 
@@ -1253,2 +1272,3 @@
 
+#ifndef __NetBSD__
 int
@@ -1273,3 +1293,3 @@
 }
-
+#else
 /******************************************************************************
@@ -1286,36 +1306,39 @@
  ****************************************************************************/
-/*int
+
+int
 PtyMasterOpen(char *ptyName)
 {
-    int ptyMasterFd;
-    char *ptr1, *ptr2;
-
-    strcpy(ptyName, "/dev/ptyXY");
-
-    ASSERT(strlen(ptyName) < PTY_PATH_LENGTH);
-
-    // array index: 0123456789 (for references in following code)
-    for(ptr1 = "pqrstuvwxyzPQRST"; *ptr1 != 0; ptr1++) {
-	ptyName[8] = *ptr1;
-	for(ptr2 = "0123456789abcdef"; *ptr2 != 0; ptr2++) {
-	    ptyName[9] = *ptr2;
-
-	    if((ptyMasterFd = open(ptyName, O_RDWR)) == -1) {
-		if(errno == ENOENT) {
-		    return -1;
-		} else {
-		    continue;
-		}
-	    }
-
-	    ptyName[5] = 't'; // need to change string to "tty" so that this
-                              // string can be used later to open the slave
-                              // end of the pty by PtyChildOpen
-	    return ptyMasterFd;
+  int ptyMasterFd;
+  char *ptr1, *ptr2;
+  
+  strcpy(ptyName, "/dev/ptyXY");
+
+  ASSERT(strlen(ptyName) < PTY_PATH_LENGTH);
+
+  // array index: 0123456789 (for references in following code)
+  for(ptr1 = "pqrstuvwxyzPQRST"; *ptr1 != 0; ptr1++) {
+    ptyName[8] = *ptr1;
+    for(ptr2 = "0123456789abcdef"; *ptr2 != 0; ptr2++) {
+      ptyName[9] = *ptr2;
+
+      if((ptyMasterFd = open(ptyName, O_RDWR)) == -1) {
+	if(errno == ENOENT) {
+	  return -1;
+	} else {
+	  continue;
 	}
+      }
+
+      ptyName[5] = 't'; // need to change string to "tty" so that this
+      // string can be used later to open the slave
+      // end of the pty by PtyChildOpen
+      return ptyMasterFd;
     }
+  }
 
-    return -1;
-}*/
+  return -1;
+}
+#endif
 
+#ifndef __NetBSD__
 int
@@ -1366,3 +1389,3 @@
 }
-
+#else
 /******************************************************************************
@@ -1399,3 +1422,3 @@
 }
-
+#endif
 /******************************************************************************
@@ -1802,3 +1825,7 @@
 	   (received the SIG_STOP or SIG_CONT possibly) */
+#ifdef __NetBSD__
+	if ((WIFSTOPPED(procStat)) || (WIFSIGNALED(procStat))) {
+#else
 	if ((WIFSTOPPED(procStat)) || (WIFCONTINUED(procStat))) {
+#endif
 	    // BUGBUG Shouldn't we signal the startup here????