Citing Debian bug #513464:
when signing something with my smartcard, gpg prompts me to insert the card
if it isn't there already; after that happens, gpg's exit status is nonzero
even if the signature worked (as indicated by the signature counter on the
card), causing the caller to discard the signature and fail.
This sounds like a true bug. Can you reproduce it?