Changeset 2423 for trunk/src/kash/redir.c
- Timestamp:
- Oct 18, 2010, 1:43:35 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/redir.c
r2290 r2423 383 383 return newfd; 384 384 } 385 386 387 /* 388 * Copy a file descriptor to be = to. Returns -1 389 * if the source file descriptor is closed, EMPTY if there are no unused 390 * file descriptors left. 391 */ 392 393 int 394 copyfd2(shinstance *psh, int from, int to) 395 { 396 int newfd; 397 398 /** @todo Use dup2()... */ 399 newfd = shfile_fcntl(&psh->fdtab, from, F_DUPFD, to); 400 if (newfd < 0) { 401 if (errno == EMFILE) 402 return EMPTY; 403 else 404 error(psh, "%d: %s", from, strerror(errno)); 405 } 406 else if (newfd != to) { 407 error(psh, "%d: F_DUPFD returned %d, expected %d", from, newfd, to); 408 close(newfd); 409 newfd = -1; 410 } 411 412 return newfd; 413 } 414
Note:
See TracChangeset
for help on using the changeset viewer.