I was looking a bit deeper into the gnupg code and debug messages. As soon as I
plug out the yubikey the usb smartcard reader including the internal smartcard
is no longer available. GnuPG is sending the following messages:
hang=0
status=7 changecnt=1
hang=0
service (0x8010001d)
sw=0x1000b status=7 changecnt=1
Error Message 0x8010001d == SCARD_E_NO_SERVICE (The Smart card resource manager
is not running.)
285d2ad881c04bee8
Now there's an internal mapping happing from 0x8010001d to sw=0x1000b
?
p=gnupg.git;a=blob;f=scd/apdu.c;h=95a25611b7ff46c87e2e888643bec0a10454f894;hb=H
EAD#l899
The SCD internal resulting error is 0x1000b means SW_HOST_GENERAL_ERROR which
is the default error if nothing else has matched yet.
The next lines in the logfiles are showing a different pcsc error code.
hang=0
stopped (0x8010001e)
sw=0x1000b status=7 changecnt=1
Error Message 0x8010001d == SCARD_E_SERVICE_STOPPED (The Smart card resource
manager has shut down.)
db1c9516ccc0dd9a0
The pcsc error code is still mapped to the generic error code (0x1000b)
possible resolution: I've no clue if the error codes 0x8010001d or 0x8010001e
are thrown in different scenarios. But if we would map those 2 messages to the
internal SW_HOST_NO_READER error the scdaemon would like remove the (likely
disconnected usb) reader from the current list, resulting in freeing up the
used card.
I can't verify this idea cause I'm not able to compile gnupg under windows but
I've attached a solution patch in this ticket