git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 1/2] t9300-fast-import: store the PID in a variable instead of pidfile

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Dec 6, 2019, 19:03 UTC
Message-ID
<20191206190331.29443-2-szeder.dev@gmail.com>
In-Reply-To
<20191206190331.29443-1-szeder.dev@gmail.com>

The five tests running 'git fast-import' in the background in 't9300-fast-import.sh' store the PID of that background process in a pidfile, to be used to check whether that background process survived each test and then to kill it in test_when_finished commands. To achieve this all these five tests run three $(cat <pidfile>) command substitutions each.

Store the PID of the background 'git fast-import' in a variable to avoid those extra processes.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 t/t9300-fast-import.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index e707fb861e..6820ebbb63 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -3165,12 +3165,12 @@ background_import_then_checkpoint () {
 	rm V.output
 
 	git fast-import $options <&8 >&9 &
-	echo $! >V.pid
+	fi_pid=$!
 	# We don't mind if fast-import has already died by the time the test
 	# ends.
 	test_when_finished "
 		exec 8>&-; exec 9>&-;
-		kill $(cat V.pid) && wait $(cat V.pid)
+		kill $fi_pid && wait $fi_pid
 		true"
 
 	# Start in the background to ensure we adhere strictly to (blocking)
@@ -3202,7 +3202,7 @@ background_import_then_checkpoint () {
 }
 
 background_import_still_running () {
-	if ! kill -0 "$(cat V.pid)"
+	if ! kill -0 "$fi_pid"
 	then
 		echo >&2 "background fast-import terminated too early"
 		false
-- 
2.24.0.801.g241c134b8d
Previous: SZEDER GáborNext: SZEDER Gábor
Message 6 of 7 in “t9300-fast-import: don't hang if background fast-import exits too early”
  1. t9300-fast-import: don't hang if background fast-import exits too earlySZEDER Gábor, Nov 30, 2019
  2. Junio C HamanoNov 30, 2019
  3. SZEDER GáborDec 1, 2019
  4. Junio C HamanoDec 1, 2019
  5. 0/2 t9300-fast-import: don't hang if background fast-import exits too earlySZEDER Gábor, Dec 6, 2019
  6. 1/2 t9300-fast-import: store the PID in a variable instead of pidfileSZEDER Gábor, Dec 6, 2019
  7. 2/2 t9300-fast-import: don't hang if background fast-import exits too earlySZEDER Gábor, Dec 6, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.