If no processes are running, listing the secret keys via `gpg -K` and `gpgsm -K` will show no results on the first run. It looks like `gpg-agent` is not started (`General Error`, no log written for it).
**Notes:**
- Listing the public keys via `gpg -k` and `gpgsm -k` does work.
- Without keyboxd the first listing works
- Might be related to {https://dev.gnupg.org/T8012}
- Okular won't find keys on the first signing operation (if no processes were running and the keyring contains only smime certs), this should be tested too, after this is fixed.
- Sometimes (every ~10-20 times) I experienced a hang on `gpg(sm) -v -K` on the first run. Killing keyboxd results in the continuation of the gpg process (without output). More details below.
**To reproduce:**
1. Ensure some certificates are in the keyring (e.g. our testcerts: public keys for all pgp/smime , secret keys for ted/edward for pgp/smime, root cert)
2. Ensure no processes are running: `gpgconf -K all`
3. Enter `gpg -K` twice -> no output on first time
```
C:\Users\g10>gpgconf -K all
C:\Users\g10>gpg -v -K
gpg: enabled compatibility flags:
gpg: using pgp trust model
gpg: no running keyboxd - starting 'C:\\Program Files\\Gpg4win\\..\\GnuPG\\bin\\keyboxd.exe'
C:\Users\g10>gpg -v -K
gpg: enabled compatibility flags:
gpg: using pgp trust model
gpg: no running gpg-agent - starting 'C:\\Program Files\\Gpg4win\\..\\GnuPG\\bin\\gpg-agent.exe'
[keyboxd]
---------
sec rsa3072 2023-03-08 [SC]
11A9C6D06717C4E284960BA906E28F5FB5297489
uid [ultimate] Edward Tester <Edward.Tester@demo.gnupg.com>
ssb rsa3072 2023-03-08 [E]
756613A147108F13282B8B7B037BFD4B2C571A9E
sec rsa3072 2023-03-08 [SC]
98111E67AE06F2BEFD2BDE10C5D6C919005F36A4
uid [ultimate] Ted Tester <Ted.Tester@demo.gnupg.com>
ssb rsa3072 2023-03-08 [E]
CC5274CB8072E9778DADD15BCD573B2B0736643A
```
4. Ensure no processes are running: `gpgconf -K all`
5. Enter `gpgsm -K` twice -> no output on first time
```
C:\Users\g10>gpgconf -K all
C:\Users\g10>gpgsm -v -K
gpgsm: enabled compatibility flags:
gpgsm: no running keyboxd - starting 'C:\\Program Files\\Gpg4win\\..\\GnuPG\\bin\\keyboxd.exe'
[keyboxd]
---------
C:\Users\g10>gpgsm -v -K
gpgsm: enabled compatibility flags:
gpgsm: no running gpg-agent - starting 'C:\\Program Files\\Gpg4win\\..\\GnuPG\\bin\\gpg-agent.exe'
[keyboxd]
---------
ID: 0x8C7DDFC5
S/N: 4D9528785EE3E701
(dec): 5590419009903519489
Issuer: /CN=Root-CA 2020/OU=GnuPG.com/O=g10 Code GmbH/C=DE
[...]
```
---
**gpg.log** (for `gpg -v -K`)
```
2026-01-23 13:53:56 gpg[9104] enabled debug flags: packet mpi crypto filter iobuf memory cache memstat trust hashing ipc recsel clock lookup extprog keydb
2026-01-23 13:53:56 gpg[9104] enabled compatibility flags:
2026-01-23 13:53:56 gpg[9104] DBG: [no clock] start
2026-01-23 13:53:56 gpg[9104] using pgp trust model
2026-01-23 13:53:56 gpg[9104] DBG: [no clock] keydb_new
2026-01-23 13:53:56 gpg[9104] no running keyboxd - starting 'C:\\Program Files\\Gpg4win\\..\\GnuPG\\bin\\keyboxd.exe'
2026-01-23 13:53:56 gpg[9104] waiting for the keyboxd to come up ... (8s)
2026-01-23 13:53:56 gpg[9104] DBG: chan_0x000000000000025c <- # Home: C:\Users\g10\AppData\Roaming\gnupg
2026-01-23 13:53:56 gpg[9104] DBG: chan_0x000000000000025c <- # Config: [none]
2026-01-23 13:53:56 gpg[9104] DBG: chan_0x000000000000025c <- OK Keyboxd 2.5.16 at your service, process 696
2026-01-23 13:53:56 gpg[9104] connection to the keyboxd established
2026-01-23 13:53:56 gpg[9104] DBG: chan_0x000000000000025c -> GETINFO version
2026-01-23 13:53:56 gpg[9104] DBG: chan_0x000000000000025c <- D 2.5.16
2026-01-23 13:53:56 gpg[9104] DBG: chan_0x000000000000025c <- OK
2026-01-23 13:53:56 gpg[9104] DBG: chan_0x000000000000025c -> SENDFD 0000000000000294
2026-01-23 13:53:56 gpg[9104] DBG: chan_0x000000000000025c <- OK
2026-01-23 13:53:56 gpg[9104] DBG: chan_0x000000000000025c -> OUTPUT FD
2026-01-23 13:53:56 gpg[9104] DBG: chan_0x000000000000025c <- OK
2026-01-23 13:53:56 gpg[9104] DBG: [no clock] keydb_search_reset
2026-01-23 13:53:56 gpg[9104] DBG: keydb_search_reset (hd=0x0000000000fbc370)
2026-01-23 13:53:56 gpg[9104] DBG: [no clock] keydb_search enter
2026-01-23 13:53:56 gpg[9104] DBG: keydb_search: 1 search descriptions:
2026-01-23 13:53:56 gpg[9104] DBG: keydb_search 0: FIRST
2026-01-23 13:53:56 gpg[9104] DBG: chan_0x000000000000025c -> SEARCH --openpgp
2026-01-23 13:53:56 gpg[9104] DBG: chan_0x000000000000025c <- S PUBKEY_INFO 1 11A9C6D06717C4E284960BA906E28F5FB5297489 -- 0 0
2026-01-23 13:53:56 gpg[9104] DBG: chan_0x000000000000025c <- OK
2026-01-23 13:53:56 gpg[9104] DBG: found UBID (0,1): 11a9c6d06717c4e284960ba906e28f5fb5297489
[...]
2026-01-23 13:53:56 gpg[9104] no running gpg-agent - starting 'C:\\Program Files\\Gpg4win\\..\\GnuPG\\bin\\gpg-agent.exe'
2026-01-23 13:53:56 gpg[9104] CreateProcess failed: ec=87
2026-01-23 13:53:56 gpg[9104] failed to start gpg-agent 'C:\\Program Files\\Gpg4win\\..\\GnuPG\\bin\\gpg-agent.exe': General error
2026-01-23 13:53:56 gpg[9104] can't connect to the gpg-agent: General error
2026-01-23 13:53:56 gpg[9104] DBG: free_packet() type=6
2026-01-23 13:53:56 gpg[9104] DBG: free_packet() type=13
2026-01-23 13:53:56 gpg[9104] DBG: free_packet() type=2
2026-01-23 13:53:56 gpg[9104] DBG: free_packet() type=2
2026-01-23 13:53:56 gpg[9104] DBG: free_packet() type=14
2026-01-23 13:53:56 gpg[9104] DBG: free_packet() type=2
2026-01-23 13:53:56 gpg[9104] DBG: [no clock] keydb_search enter
2026-01-23 13:53:56 gpg[9104] DBG: keydb_search: 1 search descriptions:
2026-01-23 13:53:56 gpg[9104] DBG: keydb_search 0: NEXT
[...]
```
**gpgsm.log** (for `gpgsm -v -K`)
- Can't be created due to {https://dev.gnupg.org/T8053}
- Using the `gpg(sm) --debug-all` flag seems to omit the important lines on stdout/stderr
---
##### Hang
Regarding the hang it seems keyboxd is stuck in a loop:
**keyboxd.log** (debug-all):
```
2026-01-23 13:44:21 keyboxd[1236] DBG: chan_0x00000000000001ec -> # Home: C:\Users\g10\AppData\Roaming\gnupg
2026-01-23 13:44:21 keyboxd[1236] DBG: chan_0x00000000000001ec -> # Config: [none]
2026-01-23 13:44:21 keyboxd[1236] DBG: chan_0x00000000000001ec -> OK Keyboxd 2.5.16 at your service, process 1236
2026-01-23 13:44:21 keyboxd[1236] DBG: chan_0x00000000000001ec <- GETINFO pid
2026-01-23 13:44:21 keyboxd[1236] DBG: chan_0x00000000000001ec -> D 1236
2026-01-23 13:44:21 keyboxd[1236] DBG: chan_0x00000000000001ec -> OK
2026-01-23 13:44:21 keyboxd[1236] DBG: chan_0x00000000000001ec <- BYE
2026-01-23 13:44:21 keyboxd[1236] DBG: chan_0x00000000000001ec -> OK closing connection
2026-01-23 13:45:21 keyboxd[1236] DBG: chan_0x00000000000002dc -> # Home: C:\Users\g10\AppData\Roaming\gnupg
2026-01-23 13:45:21 keyboxd[1236] DBG: chan_0x00000000000002dc -> # Config: [none]
2026-01-23 13:45:21 keyboxd[1236] DBG: chan_0x00000000000002dc -> OK Keyboxd 2.5.16 at your service, process 1236
2026-01-23 13:45:21 keyboxd[1236] DBG: chan_0x00000000000002dc <- GETINFO pid
2026-01-23 13:45:21 keyboxd[1236] DBG: chan_0x00000000000002dc -> D 1236
2026-01-23 13:45:21 keyboxd[1236] DBG: chan_0x00000000000002dc -> OK
2026-01-23 13:45:21 keyboxd[1236] DBG: chan_0x00000000000002dc <- BYE
2026-01-23 13:45:21 keyboxd[1236] DBG: chan_0x00000000000002dc -> OK closing connection
2026-01-23 13:46:21 keyboxd[1236] DBG: chan_0x00000000000002d4 -> # Home: C:\Users\g10\AppData\Roaming\gnupg
2026-01-23 13:46:21 keyboxd[1236] DBG: chan_0x00000000000002d4 -> # Config: [none]
2026-01-23 13:46:21 keyboxd[1236] DBG: chan_0x00000000000002d4 -> OK Keyboxd 2.5.16 at your service, process 1236
2026-01-23 13:46:21 keyboxd[1236] DBG: chan_0x00000000000002d4 <- GETINFO pid
2026-01-23 13:46:21 keyboxd[1236] DBG: chan_0x00000000000002d4 -> D 1236
2026-01-23 13:46:21 keyboxd[1236] DBG: chan_0x00000000000002d4 -> OK
2026-01-23 13:46:21 keyboxd[1236] DBG: chan_0x00000000000002d4 <- BYE
2026-01-23 13:46:21 keyboxd[1236] DBG: chan_0x00000000000002d4 -> OK closing connection
[...]
```
**procmon output** (filtered by "process name contains keyboxd"):
```
13:47:42,4841253 keyboxd.exe 1236 CreateFile C:\Users\g10\AppData\Roaming SUCCESS Desired Access: Read Data/List Directory, Synchronize, Disposition: Open, Options: Directory, Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
13:47:42,4841993 keyboxd.exe 1236 QueryDirectory C:\Users\g10\AppData\Roaming\gnupg SUCCESS FileInformationClass: FileBothDirectoryInformation, Filter: gnupg, 2: gnupg
13:47:42,4842612 keyboxd.exe 1236 CloseFile C:\Users\g10\AppData\Roaming SUCCESS
13:47:46,4954717 keyboxd.exe 1236 CreateFile C:\Users\g10\AppData\Roaming SUCCESS Desired Access: Read Data/List Directory, Synchronize, Disposition: Open, Options: Directory, Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
13:47:46,4955659 keyboxd.exe 1236 QueryDirectory C:\Users\g10\AppData\Roaming\gnupg SUCCESS FileInformationClass: FileBothDirectoryInformation, Filter: gnupg, 2: gnupg
13:47:46,4956388 keyboxd.exe 1236 CloseFile C:\Users\g10\AppData\Roaming SUCCESS
13:47:50,5068457 keyboxd.exe 1236 CreateFile C:\Users\g10\AppData\Roaming SUCCESS Desired Access: Read Data/List Directory, Synchronize, Disposition: Open, Options: Directory, Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
13:47:50,5069489 keyboxd.exe 1236 QueryDirectory C:\Users\g10\AppData\Roaming\gnupg SUCCESS FileInformationClass: FileBothDirectoryInformation, Filter: gnupg, 2: gnupg
13:47:50,5070233 keyboxd.exe 1236 CloseFile C:\Users\g10\AppData\Roaming SUCCESS
[...]
```