[NPTH] npth and fork

NIIBE Yutaka gniibe at fsij.org
Tue Oct 4 02:49:11 CEST 2016


On 10/03/2016 12:44 PM, NIIBE Yutaka wrote:
> On 10/03/2016 10:13 AM, NIIBE Yutaka wrote:
>> The specific use case of fork to daemonize a program should be done
>> _before_ calling npth_init, ideally.
>>
>> I'm going to examine code of gpg-agent and scdaemon if fix is easy.
> 
> Here is the change.  We also have dirmngr.
> 
> This change may be fragile.  No call/access should be done before
                                            /\
					    of npth_*
> npth_init and I tried to do so, but possibly, I missed.

For gpg-agent, I found npth_* calls through assuan_connect, and fixed
by deferring call of assuan_set_system_hooks.

Also for gpg-agent, I found gnupg_sleep calls npth_*.  It is fixed by
introducing thread_init_once.

Then, I pushed the change to master.


Now, I would like to change nPth for macOS.  Currently, it uses named
semaphore detecting the failure of sem_init at runtime.  I think
that use of unnamed semaphore of Grand Central Dispatch is better.
-- 



More information about the Gnupg-devel mailing list