static fork strerror and how they interact.
Wed Oct 29 18:37:00 GMT 2014
You have to use strerror_r. If you fork from a mullithreaded process you can't
allocate memory safely though. An ugly hack to solve the problem is to spawn a
thread using pthread_create, unshare the file descriptor table and whatever else
stuff you need, do a lot of normally unsafe things, then vfork and then execve.
I'm not sure if it'd be safe to call strerror_r or not though. You'd have to
know if strerror_r caches an open file descriptor to stuff for later use or not
(because if the file descriptor table is unshared then the newly allocated file
descriptor for a database wouldn't exist in the other threads' file descriptor
table, likewise the reverse problem exists if a file descriptor database is
opened by other threads concurrently and then cached.) It's probably simplest to
just use a pipe to send the error to the process you fork from instead and let
that process call strerror or strerror_r.
More information about the Libc-help