From 3e4d110fd21271e1d2765fc7c47cbf0dc3d0f1b7 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Mon, 9 Mar 2020 20:05:23 +0100 Subject: [PATCH] Add stderr redirection the regular way --- src/backend.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/backend.c b/src/backend.c index 7e7caee89..b020825e9 100644 --- a/src/backend.c +++ b/src/backend.c @@ -369,8 +369,26 @@ static bool opencl_test_instruction (hashcat_ctx_t *hashcat_ctx, cl_context cont OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; + const int fd_stderr = fileno (stderr); + + #ifndef DEBUG + const int stderr_bak = dup (fd_stderr); + #ifdef _WIN + const int tmp = open ("NIL", O_WRONLY); + #else + const int tmp = open ("/dev/null", O_WRONLY); + #endif + dup2 (tmp, fd_stderr); + close (tmp); + #endif + const int CL_rc = ocl->clBuildProgram (program, 1, &device, NULL, NULL, NULL); + #ifndef DEBUG + dup2 (stderr_bak, fd_stderr); + close (stderr_bak); + #endif + if (CL_rc != CL_SUCCESS) { #if defined (DEBUG)