From 99f8e6593ea8f581d389e972420dc0abd273ce21 Mon Sep 17 00:00:00 2001 From: Vincent Riquer Date: Sat, 14 Feb 2026 05:37:58 +0100 Subject: [PATCH] quickfix: don't hang waiting on bg jobs with SQL debug --- lib/database/close | 3 ++- lib/database/open | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/database/close b/lib/database/close index 9fb38ca..fbb829e 100644 --- a/lib/database/close +++ b/lib/database/close @@ -3,7 +3,8 @@ closeDatabase() { echo 'vacuum;' >&3 echo .quit >&3 (( debug )) && echo -n "Waiting for SQLite to terminate... " - wait + (( debug > 2 )) && exec 5>&- + wait $db_pid (( debug )) && echo OK exec 3>&- exec 4<&- diff --git a/lib/database/open b/lib/database/open index c11da4f..0b65032 100644 --- a/lib/database/open +++ b/lib/database/open @@ -1,11 +1,15 @@ #!/usr/bin/env bash openDatabase() { + local \ + populate_db + [[ -f "$database" ]] || populate_db=1 rm -f "$tempdir"/sqlite.{in,out} mkfifo "$tempdir"/sqlite.{in,out} sqlite3 -bail "$database" \ < "$tempdir/sqlite.in" \ > "$tempdir/sqlite.out" & + db_pid=$! exec 3> "$tempdir"/sqlite.in exec 4< "$tempdir"/sqlite.out rm "$tempdir"/sqlite.in "$tempdir"/sqlite.out @@ -23,4 +27,5 @@ openDatabase() { read -u4 unset REPLY checkDatabaseVersion + echo $db_pid }