Skip to content

smartpgp/run-card.sh: fix so it doesn't wait a fixed time

Lars Wirzenius requested to merge (removed):liw/run-card.sh into main

Previously the always script waited for ten seconds ("sleep 10") before running opensc-tool the virtual card it started in the background. The wait was to allow the background process to start up properly. Ten seconds turned out to not always be long enough: in 100 tries on my development computer, it failed at least once, sometimes a few times.

Replace the fixed with with a loop that waits one second and then tries to use opensc-tool, and if that fail, tries again, until a maximum time has passed. I set the maximum time arbitrarily to 20 seconds, but it's easy to adjust by changing the value of the "timeout" variable.

As an additional benefit, when the virtual card starts quickly, the normal run time of the scripts drops, for me, from about 13 seconds to 6.

Sponsored-by: NLnet Foundation; NGI Assure

Merge request reports