Skip to contentSkip to conversation

clone() + glibc thread safe?

DISCUSSION Russell Leighton 2 participants 2 messages Jan 12, 2006

lore
Share & tools
lore
#0 lore raw

Can you safely use glibc functions in a thread safe way (e.g., malloc() and friends) from threads generated by:

clone(f, stack, CLONE_FS|CLONE_FILES|CLONE_VM, t)

Thx

Russ

#1 lore raw
Quoted 4 lines · Russell Leighton

Can you safely use glibc functions in a thread safe way (e.g., malloc() and friends) from threads generated by:

clone(f, stack, CLONE_FS|CLONE_FILES|CLONE_VM, t)

no

unless you tell glibc you're using threads (by using the glibc threading primitives) glibc doesn't provide such thread safety.
(glibc at runtime knows you have threads and switches to thread-safe operations)