Skip to content
Merged
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
19 changes: 7 additions & 12 deletions Source/StdoutLogger.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,29 +92,24 @@ namespace android::StdoutLogger

g_started = false;

// Close the write ends of the pipes. This signals EOF to the reader
// threads, which will then call fclose() to close the read ends.
// Do NOT close the read ends here: fdopen() transferred ownership of
// fd[0] to the FILE* inside the reader thread, and calling close() on
// an fd owned by a FILE* is a fdsan violation on Android API 29+.
Comment thread
CedricGuillemet marked this conversation as resolved.
if (fd_stdout[1] != -1)
{
close(fd_stdout[1]);
fd_stdout[1] = -1;
}

if (fd_stdout[0] != -1)
{
close(fd_stdout[0]);
fd_stdout[0] = -1;
}
fd_stdout[0] = -1; // owned by reader thread's FILE*; closed via fclose()

Comment thread
CedricGuillemet marked this conversation as resolved.
if (fd_stderr[1] != -1)
{
close(fd_stderr[1]);
fd_stderr[1] = -1;
}

if (fd_stderr[0] != -1)
{
close(fd_stderr[0]);
fd_stderr[0] = -1;
}
fd_stderr[0] = -1; // owned by reader thread's FILE*; closed via fclose()
Comment thread
CedricGuillemet marked this conversation as resolved.
}

bool IsStarted()
Expand Down