From 686892dd06d517073f8b87a36313c377fa938abc Mon Sep 17 00:00:00 2001 From: Siddarth Kumar Date: Thu, 4 Sep 2025 12:09:50 +0400 Subject: [PATCH 1/2] pcscd: auto exit when not in use MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes `libusb` being busy when app is closed and started again. ``` starting pcscd with /tmp/.mount_StatusKDpnfI/usr/bin/pcscd -f & 00000000 [136864157226944] ccid_usb.c:672:OpenUSBByName() Can't claim interface 3/5: LIBUSB_ERROR_BUSY 00000172 [136864157226944] ifdhandler.c:160:CreateChannelByNameOrChannel() failed 00000003 [136864157226944] ../src/readerfactory.c:1132:RFInitializeReader() Open Port 0x200000 Failed (usb:058f/9540:libudev:0:/dev/bus/usb/003/005) 00000003 [136864157226944] ../src/readerfactory.c:371:RFAddReader() Alcor Micro AU9540 init failed. 00000043 [136864157226944] ../src/hotplug_libudev.c:517:HPAddDevice() Failed adding USB device: Alcor Micro AU9540 qt.core.qobject.connect: QObject::connect(QObject, Unknown): invalid nullptr parameter ``` https://man.freebsd.org/cgi/man.cgi?query=pcscd&sektion=8&manpath=freebsd-release-ports#end Screenshot 2025-09-04 at 12 11 18 PM fixes: https://github.com/status-im/status-desktop/issues/18635 --- AppRun | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AppRun b/AppRun index c221baa90ad..ce405e22ced 100755 --- a/AppRun +++ b/AppRun @@ -20,8 +20,8 @@ export PCSCLITE_CONFIG_DIR="${APPDIR}/etc/reader.conf.d" PCSCD_RUN_DIR="/tmp/pcscd/run" rm -rf "${PCSCD_RUN_DIR}" mkdir -p "${PCSCD_RUN_DIR}" -echo "starting pcscd with ${APPDIR}/usr/bin/pcscd -f &" -"${APPDIR}/usr/bin/pcscd" -f & +echo "starting pcscd with ${APPDIR}/usr/bin/pcscd --foreground --auto-exit &" +"${APPDIR}/usr/bin/pcscd" --foreground --auto-exit & DEFAULT_LANG=en_US.UTF-8 if [[ "$LANG" == "C.UTF-8" ]] From 4ef7c2f682c2e8417aa64c4dd62fc745f693bf63 Mon Sep 17 00:00:00 2001 From: Siddarth Kumar Date: Thu, 4 Sep 2025 20:54:50 +0400 Subject: [PATCH 2/2] pcscd: kill orphans --- AppRun | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/AppRun b/AppRun index ce405e22ced..239c8527016 100755 --- a/AppRun +++ b/AppRun @@ -20,8 +20,20 @@ export PCSCLITE_CONFIG_DIR="${APPDIR}/etc/reader.conf.d" PCSCD_RUN_DIR="/tmp/pcscd/run" rm -rf "${PCSCD_RUN_DIR}" mkdir -p "${PCSCD_RUN_DIR}" + +cleanup_pcscd() { + if [ -n "$PCSCD_PID" ] && kill -0 "$PCSCD_PID" 2>/dev/null; then + echo "Killing pcscd process $PCSCD_PID" + kill "$PCSCD_PID" 2>/dev/null + wait "$PCSCD_PID" 2>/dev/null + fi +} + +trap cleanup_pcscd EXIT TERM INT + echo "starting pcscd with ${APPDIR}/usr/bin/pcscd --foreground --auto-exit &" "${APPDIR}/usr/bin/pcscd" --foreground --auto-exit & +PCSCD_PID=$! DEFAULT_LANG=en_US.UTF-8 if [[ "$LANG" == "C.UTF-8" ]]