From 181a3fa5e4c242d72d311f5baa771c680647eda7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Feb 2021 10:58:29 +0100 Subject: swrap: wrap __close_nocancel() if available While it's no possible to inject swrap__close_nocancel() into libc.so.6 directly, because it's no weak symbol, it seems to be possible to inject it to other glibc libraries like libpthread.so.0, which is better than nothing. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14640 Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- tests/test_tcp_dup2.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_tcp_dup2.c b/tests/test_tcp_dup2.c index fd6adc2..238b9a8 100644 --- a/tests/test_tcp_dup2.c +++ b/tests/test_tcp_dup2.c @@ -2,6 +2,11 @@ #include #include +#include + +#ifdef HAVE___CLOSE_NOCANCEL +extern int __close_nocancel(int fd); +#endif static int setup(void **state) { @@ -20,6 +25,7 @@ static int teardown(void **state) static void test_dup2_existing_open_fd(void **state) { int s, dup_s; + int rc; (void) state; /* unused */ @@ -34,7 +40,19 @@ static void test_dup2_existing_open_fd(void **state) dup_s = dup2(s, s); assert_int_equal(dup_s, s); - close(s); +#ifdef HAVE___CLOSE_NOCANCEL + rc = __close_nocancel(s); + assert_return_code(rc, errno); + rc = close(s); + assert_int_equal(rc, -1); + assert_int_equal(errno, EBADF); + rc = __close_nocancel(s); + assert_int_equal(rc, -1); + assert_int_equal(errno, EBADF); +#else + rc = close(s); + assert_return_code(rc, errno); +#endif } int main(void) { -- cgit