From 5f11ebd64f33d21b1e2f4db6b5c1790827e0a078 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 11 Feb 2013 12:19:28 +0100 Subject: Add dup() wrapper. --- src/socket_wrapper.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') 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; -- cgit