History log of /system/core/logcat/getopt_long.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
e9ade17418c2e8390d72ee694ab5c097ec765266 03-Mar-2017 Mark Salyzyn <salyzyn@google.com> 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
/system/core/logcat/getopt_long.cpp