diff options
| author | Andreas Schneider <asn@cryptomilk.org> | 2013-02-11 12:19:28 +0100 |
|---|---|---|
| committer | Andreas Schneider <asn@cryptomilk.org> | 2013-02-11 12:19:28 +0100 |
| commit | 5f11ebd64f33d21b1e2f4db6b5c1790827e0a078 (patch) | |
| tree | b021911ddff825db96ba60fa57e0c396162f72a9 /src | |
| parent | 6045fb8e371ce22de2cd529b0aed9f7ab68e0f61 (diff) | |
| download | socket_wrapper-5f11ebd64f33d21b1e2f4db6b5c1790827e0a078.tar.gz socket_wrapper-5f11ebd64f33d21b1e2f4db6b5c1790827e0a078.tar.xz socket_wrapper-5f11ebd64f33d21b1e2f4db6b5c1790827e0a078.zip | |
Add dup() wrapper.
Diffstat (limited to 'src')
| -rw-r--r-- | src/socket_wrapper.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 303069f..9f31f20 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -234,6 +234,17 @@ static int real_connect(int sockfd, return libc_connect(sockfd, addr, addrlen); } +static int (*libc_dup)(int fd); + +static int real_dup(int fd) +{ + if (libc_dup == NULL) { + *(void **)(&libc_dup) = libc_dlsym("dup"); + } + + return libc_dup(fd); +} + static int (*libc_getpeername)(int sockfd, struct sockaddr *addr, socklen_t *addrlen); @@ -2888,8 +2899,7 @@ int close(int fd) return ret; } -#if 0 -_PUBLIC_ int swrap_dup(int fd) +int dup(int fd) { struct socket_info *si; struct socket_info_fd *fi; @@ -2918,6 +2928,7 @@ _PUBLIC_ int swrap_dup(int fd) return fi->fd; } +#if 0 _PUBLIC_ int swrap_dup2(int fd, int newfd) { struct socket_info *si; |
