diff --git a/libs/circle-newlib b/libs/circle-newlib index 00b404f..584d4c2 160000 --- a/libs/circle-newlib +++ b/libs/circle-newlib @@ -1 +1 @@ -Subproject commit 00b404f6a3a7e8719097573520e36bc153f8301c +Subproject commit 584d4c22e18665d204f4e4169ea29f8e86f6e2ad diff --git a/samples/05-smoketest/kernel.cpp b/samples/05-smoketest/kernel.cpp index f70eced..ac35aad 100644 --- a/samples/05-smoketest/kernel.cpp +++ b/samples/05-smoketest/kernel.cpp @@ -33,6 +33,7 @@ #include #include #include +#include using namespace std; @@ -597,7 +598,7 @@ CKernel::IoTest (void) } { - Report ("dup () and dup2 () tests"); + Report ("dup (), dup2 (), fcntl () tests"); int const original_fd = fileno (redirected_stdout); @@ -628,9 +629,19 @@ CKernel::IoTest (void) assert (fd_copy2 > fd_copy); - if (write (fd_copy2, dup_text, sizeof (dup_text) - 1) == -1) + int const fd_copy3 = fcntl (fd_copy2, F_DUPFD, 0); + + if (fd_copy3 == -1) + { + PErrorExit ("fcntl () failed"); + } + + assert (fd_copy3 > fd_copy); + assert (fd_copy3 > fd_copy2); + + if (write (fd_copy3, dup_text, sizeof (dup_text) - 1) == -1) { - PErrorExit ("write () via fd_copy2 failed"); + PErrorExit ("write () via fd_copy3 failed"); } if (close (fd_copy) < 0) @@ -642,6 +653,11 @@ CKernel::IoTest (void) { PErrorExit ("close (fd_copy2) failed"); } + + if (close (fd_copy3) < 0) + { + PErrorExit ("close (fd_copy3) failed"); + } } if (fclose (redirected_stdout) != 0)