On Windows, removed card is not detected correctly in some cases, and the status will be persistent (even if killed scdaemon).
Possibly, our use of PC/SC is not good. Workarounds would be:
- Use PCSC_SCOPE_USER instead of PCSC_SCOPE_SYSTEM when establish the context.
- Change the way to watch the removal:
- Currently, we periodically calls SCardGetStatusChange with the PC/SC context for each reader, with timeout==0 for non-blocking
- It may be a single blocking call for all readers, by having a dedicated thread
- Or, we can use SCardStatus function, instead, with per connection handle (instead of the PC/SC context)