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 57053f8364
commit 03bbd70947
2 changed files with 6 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,5 +1,8 @@
#!/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}
@ -10,6 +13,7 @@ openDatabase() {
| stdbuf -o0 \ | stdbuf -o0 \
sed 's/::AtOM:SQL:EOL::/\x0/g;s/\(\x0\)\xA/\1/g' \ sed 's/::AtOM:SQL:EOL::/\x0/g;s/\(\x0\)\xA/\1/g' \
> "$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,out} rm "$tempdir"/sqlite.{in,out}