stdout is not getting printed with adb 1.0.36

27 views
Skip to first unread message

Chenna e

unread,
Jul 6, 2017, 9:55:07 AM7/6/17
to android-ndk


I wrote a simple android app which has the following code snippet 


int main(){   
   printf("Press q or CTRL-C to quit.\n");
   getchar();
 }



when I am executing this app with adb 1.0.36 as adb shell /system/bin/myapp

printf is not getting printed and once I give any input then it prints. If I add fflush(stdout) after printf then it prints first and then waits for user input.

But same piece of code executes as expected with adb 1.0.32 without adding fflush(stdout).

If I remove getchar() , app has only printf statement then the behaviour is same on both adbs.

Same stdout buffering issue is seen when I am debugging some other android app with lldb debugger, Here this app is waiting for debugger to connect and its not printing anything with adb 1.0.36.

stdout is getting buffered with apps that are waiting for something with adb 1.0.36.

Did anyone see this kind of issue on adb 1.0.36 ? where can find the bugs list with this adb.

if I enter into adb shell and run /system/bin/myapp I dont see this issue


Andrew Esh

unread,
Jul 7, 2017, 10:03:56 AM7/7/17
to android-ndk
When I am working on a program that prints to stdout, and I need that output captured in the logcat output, I do this:

$ adb shell stop
$ adb shell setprop log.redirect-stdio true
$ adb shell start

Perhaps you have this set, and your output is going into the logs. You could set it to false, and see if your program prints in the adb shell.
Reply all
Reply to author
Forward
0 new messages