Re: dietlibc (0.31), fork and pthreads

"Indan Zupancic" <[email protected]>
Newsgroups gmane.linux.lib.dietlibc
Message-ID <[email protected]>
Hello,

On Mon, March 1, 2010 14:23, Ingo Struck wrote:
> Hello again,
>
> it seems that I can explain now why your fd 0 is closed
> (compiled a debug version of diet-0.32). I am sorry to say that I do not
> know a good fix for it, because obviously the libpthread code relies on
> an internal pipe for the "manager" thread.
>
> Explanation:
>
> If you do not have any call to a pthread function before
> you pipe() / fork() the pthread library code is not initialized;
> there is no call to __thread_init, hence no call to __manager_thread_init,
> so the call to __thread_manager_close works on an uninitialized __manager_pipe
> (both entries are 0).
> So
>   close(mgr_recv_fd);
>   close(mgr_send_fd);
> in libpthread/pthread_internal.c, line 422 and 423 read
>   close(0);
>   close(0);
>
> This is why the call to fork() closes fd 0 within the child branch of fork.

mgr_recv_fd and mgr_send_fd should be initialized to -1 instead of 0.

Greetings,

Indan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.