Commit graph

11 commits

Author SHA1 Message Date
Elliott Hughes
f9a9537a26 Remove unused _ARC4_ATFORK() macro.
Test: treehugger
Change-Id: Ie1ac8a5512f89da34f8d04f177bc8d4a303c42d2
2023-07-18 22:44:40 +00:00
Elliott Hughes
468efc80da Reimplement popen(3)/pclose(3).
pclose(3) is now an alias for fclose(3). We could add a FORTIFY check
that you use pclose(3) if and only if you used popen(3), but there seems
little value to that when we can just do the right thing.

This patch also adds the missing locking to _fwalk --- we need to lock
both the global list of FILE*s and also each FILE* we touch. POSIX says
that "The popen() function shall ensure that any streams from previous
popen() calls that remain open in the parent process are closed in the
new child process", which we implement via _fwalk(fclose) in the child,
but we might want to just make *all* popen(3) file descriptors O_CLOEXEC
in all cases.

Ignore fewer errors in popen(3) failure cases.

Improve popen(3) test coverage.

Bug: http://b/72470344
Test: ran tests
Change-Id: Ic937594bf28ec88b375f7e5825b9c05f500af438
2018-07-11 12:15:26 -07:00
Josh Gao
c80ffece02 Defer registration of the arc4random fork-detect handler.
Previously, arc4random would register a fork-detecting pthread_atfork
handler to not have to call getpid() after a fork. pthread_atfork uses
pthread_mutex_lock, which requires the current thread to be initialized,
preventing the use of arc4random for initializing the global stack guard,
which needs to happen before the main thread has been initialized.

Extract the arc4random fork-detection flag and use the existing
arc4random fork handler to set it.

Bug: http://b/29622562
Change-Id: I98c9329fa0e489c3f78cad52747eaaf2f5226b80
2016-06-28 15:52:59 -07:00
Elliott Hughes
2b67d7dee0 Use upstream OpenBSD's arc4random.
The getentropy_linux.c is lightly modified to build on Android, but we're now
completely in sync with upstream OpenBSD's arc4random implementation.

Change-Id: If32229fc28aba908035fb38703190d41ddcabc95
2014-07-21 14:38:16 -07:00
Dmitriy Ivanov
53c3c271dc Upstream atexit
Change-Id: Ia454a2181b5058ed9783dc02b6b1805d0e4d2715
2014-07-14 12:05:16 -07:00
Elliott Hughes
0468feb286 Sync to current upstream arc4random.
This is actually revision 1.33, which is no longer the latest, but it's
as close to head as we can currently reasonably get. I've also switched
to the OpenBSD getentropy_linux.c implementation of getentropy, lightly
modified to try to report an error on failure.

Bug: 14499627
Change-Id: Ia7c561184b1f366c9bf66f248aa60f0d53535fcb
2014-06-24 14:13:48 -07:00
Elliott Hughes
f2cea021ab Clean up <stdio.h> macros.
Also neuter __isthreaded.

We should come back to try to hide struct FILE's internals for LP64.

Bug: 3453512
Bug: 3453550
Change-Id: I7e115329fb4579246a72fea367b9fc8cb6055d18
2014-03-13 14:54:53 -07:00
Kito Cheng
94d0daa2dd Clean up useless declaration in thread_private.h
Change-Id: Ie7bcdc7195a3fcbcd09a95f73b0c49e8897ad50b
2013-06-05 11:26:24 +08:00
The Android Open Source Project
1dc9e472e1 auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
The Android Open Source Project
1767f908af auto import from //depot/cupcake/@135843 2009-03-03 18:28:13 -08:00
The Android Open Source Project
6d6c82c7a0 auto import from //branches/cupcake/...@125939 2009-01-09 17:50:54 -08:00
Renamed from libc/thread_private.h (Browse further)