Hi,
I thought that I should give some more info on why I need this info.
We have a MT app(pthreads). One of the threads does a fork1. The child
process does a malloc before it does an exec. Sometimes the the call to
fork1 does not return. So at this point we have two of our processes
running. If I attach the child process through dbx and check I find that
it is stuck in malloc. I have included below the relavent lines of the
trace. The child is stuck when it is trying to acquire a lock.
Going through the man pages of fork/fork1 and pthread_atfork I
concluded that all the libraries that use locks need to call
pthread_atfork in their .init section. These man pages say that this
needs to be done to prevent any deadlocks in the child. I can probably
assume that the library supplying malloc (libc ?) is doing this
correctly.
Earlier our code would actually use fork and not fork1, but we faced
some other probs with this and found that using fork1 solved our
problem. Now we are having the above problem using fork1. From the man
page I do not find any difference between fork & fork1 in a MT app using
pthreads.
So can anybody tell me the differences between the two calls in such
an app. I cannot post any code as its too big and I have not tried to
simulate the problem in a sample app.
regards
Ranga
[1] _lwp_sema_wait(0xee305e80, 0x1, 0x0, 0x0, 0xff00, 0xff), at
0xee9396f0
[2] _park(0xee305de0, 0xee305e80, 0x0, 0xee305e5c, 0xee305e58,
0xee305e54), at 0xef24776c
[3] _mutex_adaptive_lock(0xee9a6600, 0x4c00, 0xef265250, 0x1, 0x4d58,
0xfffeffff), at 0xef2487b0
[4] _mutex_lock(0xee9a6600, 0xef265250, 0x0, 0x0, 0x0, 0x0), at
0xef2484f8
[5] malloc(0x15, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xee945a40
regards
Ranganath
> Hi,
> Can somebody tell me the differences between
> fork and fork1 on solaris 2.6 in a multi threaded
> app using pthreads. The fork/fork1 man page is not
> very clear.
> regards
> Ranganath
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.