npth_init() use sem_init with shared flag set. It creates system-wide semaphore.
There is no API provided to call sem_destroy().
gpg-agent use npth_init() long time
gpg use npth_init() starting from release 2.3.0
Each gpg and gpg-agent process create new one unnamed semaphore (exception 'gpg --version', maybe exist some more cases when not).
Test:
#>oslevel
7.1.0.0
#>ipcs -rs | grep -E '^s *-'| wc -l
373
#>gpg -r file_wallet -e test.txt
gpg: error reading symlink '/proc/curproc/file': No such file or directory
#>ipcs -rs | grep -E '^s *-'| wc -l
374
#>gpg --no-option
gpg: error reading symlink '/proc/curproc/file': No such file or directory
gpg: Warning: using insecure memory!
gpg: WARNING: no command supplied. Trying to guess what you mean ...
gpg: Go ahead and type your message ...
^C
gpg: signal 2 caught ... exiting
#>ipcs -rs | grep -E '^s *-'| wc -l
375
#>