From 59c60b80316731d3be952f0758d59e2fa87550d0 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Tue, 24 Sep 2019 10:10:26 +0200 Subject: [PATCH] test-libc: test double dup2, dup Issue #3477 Issue #3505 --- repos/libports/src/test/libc/main.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/repos/libports/src/test/libc/main.cc b/repos/libports/src/test/libc/main.cc index 40f184d1c..49170b16c 100644 --- a/repos/libports/src/test/libc/main.cc +++ b/repos/libports/src/test/libc/main.cc @@ -152,6 +152,31 @@ int main(int argc, char **argv) } } + { + /* test dup of stderr (issue #3477) */ + int const new_fd = dup(STDERR_FILENO); + if (new_fd < 0) { + printf("dup of stderr failed\n"); + ++error_count; + } else { + close(new_fd); + } + } + + { + /* test double dup2 (issue #3505) */ + int const new_fd = 17, another_new_fd = 18; + if (dup2(STDERR_FILENO, new_fd) == new_fd + && dup2(STDERR_FILENO, another_new_fd) == another_new_fd) { + + close(new_fd); + close(another_new_fd); + } else { + printf("dup2 of stderr failed\n"); + ++error_count; + } + } + perror("perror"); struct timespec ts;