[gpgme] fork() questions

Stephan Menzel stephan-menzel at web.de
Tue Feb 13 15:37:10 CET 2007


Hi there,

another not quite simple question I have regarding gpgme is: How exactly does 
it work? Am I seeing this correctly that it uses fork() to start an external 
process and communicates with it through pipes?

And if so, what happens to mutexes in that case. I often heard forking 
processes with mutexes is always messy and results in strange behaviour. 
(Stevens, "Unix IPC")

To give you an example:

I've got a multithreaded process here which uses gpgme to check signatures.
After this has run for a certain time I notice that the processe's internal 
locking (pthread mutexes) doesn't seem to work anymore. Several mutexes of my 
own apparently are not unlocked anymore.

And even more strange:
Usually when I look at the process in question I see something like this:

root      9128  0.0  0.1 33860 4584 ?    SNs  13:58   0:00 /usr/sbin/mypro
nobody  9129 40.4  2.3 140648 95904 ? SNs  13:58  29:29  \_ /usr/sbin/mypro

The demonized process and the working process with different rights.

Right now I see this:

root      9128  0.0  0.1 33860 4584 ?    SNs  13:58   0:00 /usr/sbin/mypro
nobody  9129 40.4  2.3 140648 95904 ? SNs  13:58  29:29  \_ /usr/sbin/mypro
nobody     4882  0.0  1.4 113408 61368 ?  SN   14:03  0:00 /usr/sbin/mypro
nobody     2905  0.0  2.0 138020 84748 ? SN   14:08   0:00 /usr/sbin/mypro
nobody   10988  0.0  2.1 142816 90308 ?  SN   14:56   0:00 /usr/sbin/mypro

The original two I expect to see plus several (I noticed up to three) 
additional ones. I suppose those come from gpgme which is the only thing that 
has changed. When I look at the internal thread management of this process I 
see three threads hanging for about the time when those three threads have 
been created. So I assume they are doing signature checking and are hanging 
somewhere. 
When I attach gdb to any of those processes I see something like this:

0xffffe410 in __kernel_vsyscall ()
(gdb) bt
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7b0881b in __lll_mutex_lock_wait () 
from /lib/tls/i686/cmov/libpthread.so.0
#2  0xb7b059f3 in _L_mutex_lock_26 () from /lib/tls/i686/cmov/libpthread.so.0
#3  0xb6496530 in ?? ()
#4  0x00000000 in ?? ()

What I'm afraid of now is, that gpgme might fork() in order to do it's magic 
and mess up it's own mutexes (or mine) doing so.
Does all that say anything to you guys or am I completely mistaken here?

Greetings and thanks for your help...

Stephan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : /pipermail/attachments/20070213/7bc4dfdc/attachment.pgp 


More information about the Gnupg-devel mailing list