Track whether a thread is currently vforked.
Our various fd debugging facilities get extremely confused by a vforked
process closing file descriptors in preparation to exec: fdsan can
abort, and fdtrack will delete backtraces for any file descriptors that
get closed. Keep track of whether we're in a vforked child in order to
be able to detect this.
Bug: http://b/153926671
Test: 32/64-bit bionic-unit-tests on blueline, x86_64 emulator
Change-Id: I8a082fd06bfdfef0e2a88dbce350b6f667f7df9f
diff --git a/libc/bionic/pthread_internal.h b/libc/bionic/pthread_internal.h
index ab8b955..1f055f5 100644
--- a/libc/bionic/pthread_internal.h
+++ b/libc/bionic/pthread_internal.h
@@ -70,9 +70,12 @@
pid_t tid;
private:
- pid_t cached_pid_;
+ uint32_t cached_pid_ : 31;
+ uint32_t vforked_ : 1;
public:
+ bool is_vforked() { return vforked_; }
+
pid_t invalidate_cached_pid() {
pid_t old_value;
get_cached_pid(&old_value);