儲存庫 kBuild 的更動 2288
- 時間撮記:
- 2009-2-25 上午06:21:10 (16 年 以前)
- 位置:
- trunk/src/kash
- 檔案:
-
- 修改 4 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/kash/input.c
r1233 r2288 412 412 setinputfd(shinstance *psh, int fd, int push) 413 413 { 414 (void) shfile_ fcntl(&psh->fdtab, fd, F_SETFD, FD_CLOEXEC);414 (void) shfile_cloexec(&psh->fdtab, fd, 1 /* close it */); 415 415 if (push) { 416 416 pushfile(psh); -
trunk/src/kash/shfile.c
r2281 r2288 68 68 #ifdef SH_PURE_STUB_MODE 69 69 return -1; 70 70 71 #elif defined(SH_STUB_MODE) 71 72 # ifdef _MSC_VER … … 74 75 return pipe(fds); 75 76 # endif 77 76 78 #else 77 79 #endif … … 83 85 #ifdef SH_PURE_STUB_MODE 84 86 rc = -1; 87 85 88 #elif defined(SH_STUB_MODE) 86 89 rc = dup(fd); 90 87 91 #else 88 92 #endif … … 98 102 #ifdef SH_PURE_STUB_MODE 99 103 rc = -1; 104 100 105 #elif defined(SH_STUB_MODE) 101 106 rc = close(fd); 107 102 108 #else 103 109 #endif … … 111 117 #ifdef SH_PURE_STUB_MODE 112 118 return -1; 119 113 120 #elif defined(SH_STUB_MODE) 114 121 # ifdef _MSC_VER … … 117 124 return read(fd, buf, len); 118 125 # endif 126 119 127 #else 120 128 #endif … … 125 133 #ifdef SH_PURE_STUB_MODE 126 134 return -1; 135 127 136 #elif defined(SH_STUB_MODE) 128 137 # ifdef _MSC_VER … … 131 140 return write(fd, buf, len); 132 141 # endif 142 133 143 #else 134 144 #endif … … 139 149 #ifdef SH_PURE_STUB_MODE 140 150 return -1; 151 141 152 #elif defined(SH_STUB_MODE) 142 153 return lseek(fd, off, whench); 154 143 155 #else 144 156 #endif … … 147 159 int shfile_fcntl(shfdtab *pfdtab, int fd, int cmd, int arg) 148 160 { 149 #ifdef SH_PURE_STUB_MODE 150 return -1; 151 #elif defined(SH_STUB_MODE) 152 # ifdef _MSC_VER 153 return -1; 154 # else 155 return fcntl(fd, cmd, arg); 156 # endif 157 #else 158 #endif 161 int rc; 162 #ifdef SH_PURE_STUB_MODE 163 rc = -1; 164 165 #elif defined(SH_STUB_MODE) || defined(SH_FORKED_MODE) 166 # ifdef _MSC_VER 167 switch (cmd) 168 { 169 /* Just enough F_GETFL/F_SETFL to get along with. */ 170 case F_GETFL: 171 errno = 0; 172 rc = _isatty(fd); 173 if (errno == EBADF) 174 rc = -1; 175 break; 176 177 case F_SETFL: 178 errno = 0; 179 rc = _isatty(fd); 180 if (errno != EBADF) 181 { 182 if (!arg) 183 rc = 0; 184 else 185 { 186 errno = EINVAL; 187 rc = -1; 188 } 189 } 190 else 191 rc = -1; 192 break; 193 194 case F_DUPFD: 195 { 196 # if 1 197 /* the brute force approach. */ 198 int i = 0; 199 int fds[256]; 200 for (i = 0; i < 256; i++) 201 { 202 fds[i] = -1; 203 rc = _dup(fd); 204 if (rc >= arg) 205 break; 206 fds[i] = rc; 207 } 208 while (i-- > 0) 209 close(fds[i]); 210 if (rc < arg) 211 { 212 errno = EMFILE; 213 rc = -1; 214 } 215 # else 216 /* A much quick approach which is spoiled by crash validation in the CRT. */ 217 int fdnew = arg; 218 rc = -2; 219 for (fdnew = arg; fdnew < 1024; fdnew++) 220 { 221 /* is the file open? */ 222 errno = 0; 223 _isatty(fdnew); 224 if (errno == EBADF) 225 { 226 rc = _dup2(fd, fdnew); 227 break; 228 } 229 } 230 if (rc == -2) 231 { 232 errno = EMFILE; 233 rc = -1; 234 } 235 # endif 236 break; 237 } 238 } 239 # else 240 rc = fcntl(fd, cmd, arg); 241 # endif 242 243 #else 244 #endif 245 246 #ifdef DEBUG 247 if (tracefile) 248 switch (cmd) 249 { 250 case F_GETFL: 251 TRACE2((NULL, "shfile_fcntl(%d,F_GETFL,ignored=%d) -> %d [%d]\n", fd, arg, rc, errno)); 252 break; 253 case F_SETFL: 254 TRACE2((NULL, "shfile_fcntl(%d,F_SETFL,newflags=%#x) -> %d [%d]\n", fd, arg, rc, errno)); 255 break; 256 case F_DUPFD: 257 TRACE2((NULL, "shfile_fcntl(%d,F_DUPFS,minfd=%d) -> %d [%d]\n", fd, arg, rc, errno)); 258 break; 259 default: 260 TRACE2((NULL, "shfile_fcntl(%d,%d,%d) -> %d [%d]\n", fd, cmd, arg, rc, errno)); 261 break; 262 } 263 #endif 264 return rc; 159 265 } 160 266 … … 163 269 #ifdef SH_PURE_STUB_MODE 164 270 return -1; 271 165 272 #elif defined(SH_STUB_MODE) 166 273 return stat(path, pst); 274 167 275 #else 168 276 #endif … … 173 281 #ifdef SH_PURE_STUB_MODE 174 282 return -1; 283 175 284 #elif defined(SH_STUB_MODE) 176 285 # ifdef _MSC_VER … … 179 288 return lstat(link, pst); 180 289 # endif 290 181 291 #else 182 292 #endif … … 187 297 #ifdef SH_PURE_STUB_MODE 188 298 return -1; 299 189 300 #elif defined(SH_STUB_MODE) 190 301 # ifdef _MSC_VER //??? … … 193 304 return chdir(path); 194 305 # endif 306 195 307 #else 196 308 #endif … … 201 313 #ifdef SH_PURE_STUB_MODE 202 314 return NULL; 315 203 316 #elif defined(SH_STUB_MODE) 204 317 return getcwd(buf, len); 318 205 319 #else 206 320 #endif … … 211 325 #ifdef SH_PURE_STUB_MODE 212 326 return -1; 327 213 328 #elif defined(SH_STUB_MODE) 214 329 # ifdef _MSC_VER … … 218 333 return access(path, type); 219 334 # endif 335 220 336 #else 221 337 #endif … … 244 360 #ifdef SH_PURE_STUB_MODE 245 361 rc = -1; 246 #elif defined(SH_STUB_MODE) 247 # ifdef _MSC_VER 362 363 #elif defined(SH_STUB_MODE) 364 # ifdef _MSC_VER 365 errno = ENOSYS; 248 366 rc = -1; 249 367 # else … … 251 369 | (closeit ? FD_CLOEXEC : 0)); 252 370 # endif 371 253 372 #else 254 373 #endif … … 265 384 #ifdef SH_PURE_STUB_MODE 266 385 rc = -1; 267 #elif defined(SH_STUB_MODE) 268 # ifdef _MSC_VER 386 387 #elif defined(SH_STUB_MODE) 388 # ifdef _MSC_VER 389 errno = ENOSYS; 269 390 rc = -1; 270 391 # else 271 392 rc = ioctl(fd, request, buf); 272 393 # endif 394 273 395 #else 274 396 #endif … … 283 405 #ifdef SH_PURE_STUB_MODE 284 406 return 022; 407 285 408 #elif defined(SH_STUB_MODE) 286 409 return 022; 410 287 411 #else 288 412 #endif … … 294 418 #ifdef SH_PURE_STUB_MODE 295 419 return NULL; 296 #elif defined(SH_STUB_MODE) 297 # ifdef _MSC_VER 420 421 #elif defined(SH_STUB_MODE) 422 # ifdef _MSC_VER 423 errno = ENOSYS; 298 424 return NULL; 299 425 # else 300 426 return (shdir *)opendir(dir); 301 427 # endif 428 302 429 #else 303 430 #endif … … 308 435 #ifdef SH_PURE_STUB_MODE 309 436 return NULL; 310 #elif defined(SH_STUB_MODE) 311 # ifdef _MSC_VER 437 438 #elif defined(SH_STUB_MODE) 439 # ifdef _MSC_VER 440 errno = ENOSYS; 312 441 return NULL; 313 442 # else … … 315 444 return pde ? (shdirent *)&pde->d_name[0] : NULL; 316 445 # endif 446 317 447 #else 318 448 #endif … … 323 453 #ifdef SH_PURE_STUB_MODE 324 454 return NULL; 325 #elif defined(SH_STUB_MODE) 326 # ifndef _MSC_VER 455 456 #elif defined(SH_STUB_MODE) 457 # ifdef _MSC_VER 458 errno = ENOSYS; 459 # else 327 460 closedir((DIR *)pdir); 328 461 # endif 329 #else 330 #endif 331 } 462 463 #else 464 #endif 465 } -
trunk/src/kash/tests/Makefile.kmk
r2285 r2288 62 62 echo 'kash tests: All tests succeeded.'; \ 63 63 else \ 64 echo "kash tests: $$KASH_FAILURE kash test failed"'!!'; \ 64 echo "kash tests: $$KASH_FAILURE tests failed"'!!'; \ 65 echo ""; \ 65 66 exit 1; \ 66 67 fi -
trunk/src/kash/tests/trap-exit-1
r2282 r2288 1 1 #!/bin/sh 2 set -x 2 3 3 4 trap 'echo "trap-exit-1: overriding exit 1"; exit 0' EXIT
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器