Commit graph

4 commits

Author SHA1 Message Date
Mark Salyzyn
e9ade17418 liblogcat: introduce getopt_long_r
Resolve one of the threading issues by creating a private C++ified
copy of getopt_long_r that started out its life as the bionic
getopt_long, but is reentrant.  Adds a new state context for the
stderr stream called optstderr.  Utilize this new function in logcat.
Control opterr and optstderr to match liblogcat expectations.  Correct
and fortify const.

Alternative would be to lock around _all_ getopt callers.  This has
the advantage of requiring _no_ locks that could get in the way of
using liblogcat in a signal handler.  The log reader interface does
run the risk of incurring locks and heap allocations though, so there
is more work to be done for that final goal.

Test: gTest logcat-unit-tests
Bug: 35326290
Change-Id: Ibb1b374c55d357d5d7fa5ad00bfaf07ae0bc4ba5
2017-03-06 08:40:16 -08:00
Mark Salyzyn
6dabc81a0b liblogcat: add android_logcat_popen and android_logcat_system
Supply a wrapper to the logcat API that provides some analogous
functionality to popen and system libc calls with some bits of
KISS shell-like parsing for environment, quotes and error
redirection handling.

Test: gTest logcat-unit-tests
Bug: 35326290
Change-Id: I9494ce71267ad2b2bec7fcccfc7d4beddae9aea6
2017-02-17 14:42:14 -08:00
Mark Salyzyn
1d6928b736 liblogcat: add android_logcat_run_command_thread
A non-blocking API to run a logcat function in a background thread.
Returns a read end of a pipe to collect the output.

Test: gTest logcat-unit-tests
Bug: 35326290
Change-Id: Idc14e4ad955e0b2b9fafa5d3aeed8cd7fb4069fb
2017-02-17 14:42:14 -08:00
Mark Salyzyn
c0cf90d1fb logcat: Create liblogcat
Try to leverage as much of logcat as-is and produce a viable
library API that others can use for their own logcat execution.

Added a test to check ANDROID_PRINTF_LOG environment variable.

Test: gTest logcat-unit-tests
Bug: 35326290
Change-Id: I30de692ea9d83e6fd6e5d9e7cf93d31401a88a40
2017-02-17 14:42:14 -08:00