quickfix: don't hang waiting on bg jobs with SQL debug

This commit is contained in:
Vincent Riquer 2026-02-14 05:37:58 +01:00
parent c94b6b40c3
commit 99f8e6593e
2 changed files with 7 additions and 1 deletions

View File

@ -3,7 +3,8 @@ closeDatabase() {
echo 'vacuum;' >&3 echo 'vacuum;' >&3
echo .quit >&3 echo .quit >&3
(( debug )) && echo -n "Waiting for SQLite to terminate... " (( debug )) && echo -n "Waiting for SQLite to terminate... "
wait (( debug > 2 )) && exec 5>&-
wait $db_pid
(( debug )) && echo OK (( debug )) && echo OK
exec 3>&- exec 3>&-
exec 4<&- exec 4<&-

View File

@ -1,11 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
openDatabase() { openDatabase() {
local \
populate_db
[[ -f "$database" ]] || populate_db=1 [[ -f "$database" ]] || populate_db=1
rm -f "$tempdir"/sqlite.{in,out} rm -f "$tempdir"/sqlite.{in,out}
mkfifo "$tempdir"/sqlite.{in,out} mkfifo "$tempdir"/sqlite.{in,out}
sqlite3 -bail "$database" \ sqlite3 -bail "$database" \
< "$tempdir/sqlite.in" \ < "$tempdir/sqlite.in" \
> "$tempdir/sqlite.out" & > "$tempdir/sqlite.out" &
db_pid=$!
exec 3> "$tempdir"/sqlite.in exec 3> "$tempdir"/sqlite.in
exec 4< "$tempdir"/sqlite.out exec 4< "$tempdir"/sqlite.out
rm "$tempdir"/sqlite.in "$tempdir"/sqlite.out rm "$tempdir"/sqlite.in "$tempdir"/sqlite.out
@ -23,4 +27,5 @@ openDatabase() {
read -u4 read -u4
unset REPLY unset REPLY
checkDatabaseVersion checkDatabaseVersion
echo $db_pid
} }