On Thu, 2012-11-15 at 17:13 -0500, Rich Felker wrote: > On Tue, Nov 13, 2012 at 11:31:25AM +0000, Markos Chandras wrote: > > From: Markos Chandras <markos.chand...@imgtec.com> > > > > Signed-off-by: Markos Chandras <markos.chand...@imgtec.com> > > --- > > libc/sysdeps/linux/common/dup2.c | 8 +++++++- > > 1 files changed, 7 insertions(+), 1 deletions(-) > > > > diff --git a/libc/sysdeps/linux/common/dup2.c > > b/libc/sysdeps/linux/common/dup2.c > > index 006f06b..e58105d 100644 > > --- a/libc/sysdeps/linux/common/dup2.c > > +++ b/libc/sysdeps/linux/common/dup2.c > > @@ -10,6 +10,12 @@ > > #include <sys/syscall.h> > > #include <unistd.h> > > > > - > > +#if defined(__NR_dup3) && ! defined(__NR_dup2) > > +int dup2(int old, int newfd) > > +{ > > + return dup3(old, newfd, 0); > > +} > > +#else > > _syscall2(int, dup2, int, oldfd, int, newfd) > > +#endif > > libc_hidden_def(dup2) > > This is not valid. dup3 explicitly fails if old==newfd, but dup2 is > required to work in this case. However you can't just return success > in that case, because old might not be valid. You need to perform > fcntl or something to determine if the fd is valid, and return an > error if it's not.
Markos, this was previously discussed here: http://lists.uclibc.org/pipermail/uclibc/2012-April/046737.html _______________________________________________ uClibc mailing list uClibc@uclibc.org http://lists.busybox.net/mailman/listinfo/uclibc