LudovicRousseau / pyscard

pyscard smartcard library for python
http://pyscard.sourceforge.net/
GNU Lesser General Public License v2.1
379 stars 108 forks source link

After os.fork(), pyscard in child process can't connect to pyscd service #73

Closed tombull closed 5 years ago

tombull commented 5 years ago

Error experienced on MacOS 10.14.3.

Code to replicate:

import os
pid = os.fork()
from smartcard.scard import SCardEstablishContext, SCardGetErrorMessage, SCARD_SCOPE_USER
hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
print('Result from {} process: {}'.format('child' if pid == 0 else 'parent', SCardGetErrorMessage(hresult)))

Gives result:

Result from child process: Service not available.
Result from parent process: Command successful.
tombull commented 5 years ago

Just read this blog post. It's a bug in MacOS.