Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libhb/gtk: do not modify stderr struct directly on mingw #5945

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gtk/src/application.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,8 +995,8 @@ ghb_application_handle_local_options (GApplication *app, GVariantDict *options)
{
// Non-console windows apps do not have a stderr->_file
// assigned properly
stderr->_file = STDERR_FILENO;
stdout->_file = STDOUT_FILENO;
(void) freopen("NUL", "w", stderr);
(void) freopen("NUL", "w", stdout);
}
#else
redirect_io = FALSE;
Expand Down
10 changes: 7 additions & 3 deletions libhb/hb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2297,11 +2297,15 @@ static void redirect_thread_func(void * _data)
if (pipe(pfd))
return;
#if defined( SYS_MINGW )
// dup2 doesn't work on windows for some stupid reason
stderr->_file = pfd[1];
// Non-console windows apps do not have a stderr->_file
// assigned properly
(void) freopen("NUL", "w", stderr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question, does this leave a file named "NUL" somewhere that needs to be cleaned up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not. NUL is the old DOS device which Windows will convert behind the scenes to \Device\Null, its /dev/null equivalent.

windows-nul

_dup2(pfd[1], _fileno(stderr));
#else
dup2(pfd[1], /*stderr*/ 2);
dup2(pfd[1], STDERR_FILENO);
#endif
setvbuf(stderr, NULL, _IONBF, 0);

FILE * log_f = fdopen(pfd[0], "rb");

char line_buffer[500];
Expand Down
Loading