@@ -34,9 +34,12 @@ typedef struct {
3434 int pipe [2 ];
3535} StreamInfo ;
3636
37+ // The FILE member can't be initialized here because stdout and stderr are not
38+ // compile-time constants. Instead, it's initialized immediately before the
39+ // redirection.
3740static StreamInfo STREAMS [] = {
38- {stdout , STDOUT_FILENO , ANDROID_LOG_INFO , "native.stdout" , {-1 , -1 }},
39- {stderr , STDERR_FILENO , ANDROID_LOG_WARN , "native.stderr" , {-1 , -1 }},
41+ {NULL , STDOUT_FILENO , ANDROID_LOG_INFO , "native.stdout" , {-1 , -1 }},
42+ {NULL , STDERR_FILENO , ANDROID_LOG_WARN , "native.stderr" , {-1 , -1 }},
4043 {NULL , -1 , ANDROID_LOG_UNKNOWN , NULL , {-1 , -1 }},
4144};
4245
@@ -87,6 +90,8 @@ static char *redirect_stream(StreamInfo *si) {
8790JNIEXPORT void JNICALL Java_org_python_testbed_PythonTestRunner_redirectStdioToLogcat (
8891 JNIEnv * env , jobject obj
8992) {
93+ STREAMS [0 ].file = stdout ;
94+ STREAMS [1 ].file = stderr ;
9095 for (StreamInfo * si = STREAMS ; si -> file ; si ++ ) {
9196 char * error_prefix ;
9297 if ((error_prefix = redirect_stream (si ))) {
0 commit comments