Toolio -- stdout and stderr of the android Program

Source: Internet
Author: User

Source code is toolio. cpp in the flying project (http://code.google.com/p/flying-on-android/)

This program mainly demonstrates how to redirect stdout and stderr of a program.

Processes started by the system in Android, stdout and stderr are directed to/dev/null by default. Therefore, the output of the program is invisible from the ADB shell, you can only print data by using logw and other methods, and then view data by using logcat.

However, executable binary programs started from shell are not redirected, and stdout and stderr are directed to the terminal at startup. You can compile and run toolio:

Toolio

Use the default stdout and stderr. All outputs are displayed.

Toolio Console

Redirects stdout and stderr to/dev/console. The output results are the same as those before redirection.

Toolio null

Redirects stdout and stderr to/dev/null. No output is visible after redirection.

 

This indicates that when toolio is started from the shell through the serial port, the stdout and stderr of the program are both/dev/console like toolio. Therefore, when redirected to/dev/console, the output remains unchanged.

There are many printf In the android source code, but these outputs are not visible in the serial port, because the program compiled by the source code is not started through the serial port.

In addition, stderr in Bionic of Android is not buffered by default, while stdout is buffered. If there is a buffer, the characters written to stdout will be accumulated until the buffer is full or/N is met, all the content will be printed once.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.