[Pcsclite-muscle] pcsclite on OS-X Yosemite drives me crazy
pcsclite.pkoch at dfgh.net
pcsclite.pkoch
Tue Mar 24 04:59:09 PDT 2015
Dear readers,
One of may smartcard application running under Mac OS-X suddenly stopped
working. The application does a fork() unless started in debug-mode. It took
me quite a while until I found:
http://ludovicrousseau.blogspot.de/2015/01/os-x-yosemite-bug-pcsc-functions-crash.html
It's always fun to search for a bug that disappears if you switch on
debug-mode :-)
Here's what Ludivic writes in his blog:
"I verified this behaviour only with SCardListReaders() and SCardConnect().
I would not be surprised if it is the case for all PC/SC functions (except
SCardEstablishContext() of course)."
Maybe this will surpise you: Under OS-X Yosemite EVERY PC/SC-function will
crash in
a child process if SCardEstablishContext() was called in the parent process
INCLUDING SCardEstablishContext() itself.
If SCardEstablishContext() was not called in a parent process
SCardEstablishContext() will fail in a child process with "Service not
available"
So if you are running a daemon that forks child processes your cannot use
pcsclite anymore from these child processes no matter what you try.
Any ideas??
Kind reagrds
Peter Koch
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <PCSC/pcsclite.h>
#include <PCSC/wintypes.h>
#include <PCSC/winscard.h>
int main(int argc, char *argv[]){
SCARDCONTEXT hContext;
LONG ret;
int i=1;
if(i){
ret=SCardEstablishContext(SCARD_SCOPE_USER, 0, 0,
&hContext);
printf("Parent: SCardEstablishCOntext() %s\n",
pcsc_stringify_error(ret));
SCardReleaseContext(hContext);
printf("released SCard-Context\n");
}
// Detach from controlling-terminal
i=fork();
printf("fork()=%d\n",i);
if(i) exit(0);
printf("Child\n");
ret=SCardEstablishContext(SCARD_SCOPE_USER, 0, 0, &hContext);
printf("Child: SCardEstablishCOntext() %s\n",
pcsc_stringify_error(ret));
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pcsclite-muscle/attachments/20150324/52592a87/attachment.html>
More information about the pcsclite-muscle
mailing list