Ignore:
Timestamp:
Oct 18, 2010, 1:43:35 AM (15 years ago)
Author:
bird
Message:

kash: made the SHFILE_IN_USE mode work on unix (because openbsd has a very hackish pthread library).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/redir.c

    r2290 r2423  
    383383        return newfd;
    384384}
     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
     393int
     394copyfd2(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.