Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lavabit/magma.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/check
diff options
context:
space:
mode:
authorLadar Levison <ladar@lavabit.com>2018-11-21 18:32:04 +0300
committerLadar Levison <ladar@lavabit.com>2018-11-21 18:32:04 +0300
commitd14342a0e9f606fe21a195d49330e8821fd5ada6 (patch)
tree254745a25e8355824036e311a1c51d173c83e6d1 /check
parentb47a111ea365133a4798605b40eafe866773a4fc (diff)
Cleanup the console descriptors.
Diffstat (limited to 'check')
-rw-r--r--check/magma/magma_check.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/check/magma/magma_check.c b/check/magma/magma_check.c
index 91433436..1a81cee2 100644
--- a/check/magma/magma_check.c
+++ b/check/magma/magma_check.c
@@ -374,6 +374,12 @@ int main(int argc, char *argv[]) {
process_stop();
ns_cleanup(barrister_unit_test);
+
+ // Close the console descriptors, if they are still valid.
+ if ((errno = 0) || (fcntl(STDIN_FILENO, F_GETFL) != -1 && errno != EBADF)) close(STDIN_FILENO);
+ if ((errno = 0) || (fcntl(STDOUT_FILENO, F_GETFL) != -1 && errno != EBADF)) close(STDOUT_FILENO);
+ if ((errno = 0) || (fcntl(STDERR_FILENO, F_GETFL) != -1 && errno != EBADF)) close(STDERR_FILENO);
+
exit((failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE);
}