OSDN Git Service

Prevent deadlock when using fork
authorRabin Vincent <rabin.vincent@stericsson.com>
Fri, 8 Apr 2011 06:50:48 +0000 (08:50 +0200)
committerJean-Baptiste Queru <jbq@google.com>
Tue, 6 Dec 2011 16:39:18 +0000 (08:39 -0800)
commit177ba8cb42ed6d232e7c8bcad5e6ee21fc51a0e8
tree03f7fbd00c889bd2069b088f769e53ff9cfd40e9
parente4a21c89a8b24b32f7a2637b45522dfa59f2aaa4
Prevent deadlock when using fork

When forking of a new process in bionic, it is critical that it
does not allocate any memory according to the comment in
java_lang_ProcessManager.c:
"Note: We cannot malloc() or free() after this point!
A no-longer-running thread may be holding on to the heap lock, and
an attempt to malloc() or free() would result in deadlock."
However, as fork is using standard lib calls when tracing it a bit,
they might allocate memory, and thus causing the deadlock.
This is a rewrite so that the function cpuacct_add, that fork calls,
will use system calls instead of standard lib calls.

Signed-off-by: christian bejram <christian.bejram@stericsson.com>
Change-Id: Iff22ea6b424ce9f9bf0ac8e9c76593f689e0cc86
libc/bionic/cpuacct.c