git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "SZEDER Gábor" <szeder.dev@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] t9300-fast-import: don't hang if background fast-import exits too early
Date: Sat, 30 Nov 2019 13:16:30 -0800	[thread overview]
Message-ID: <xmqqsgm512vl.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20191130104644.17350-1-szeder.dev@gmail.com> ("SZEDER Gábor"'s message of "Sat, 30 Nov 2019 11:46:44 +0100")

SZEDER Gábor <szeder.dev@gmail.com> writes:

> +	(
> +		git fast-import $options <&8 >&9 &
> +		echo $! >V.fi.pid
> +		wait $!
> +		echo >&2 "background fast-import terminated too early with exit code $?"
> +		# Un-block the read loop in the main shell process.
> +		echo >&9 UNEXPECTED
> +	) &
> +	echo $! >V.sh.pid
>  	# We don't mind if fast-import has already died by the time the test
>  	# ends.
> -	test_when_finished "
> +	test_when_finished '
>  		exec 8>&-; exec 9>&-;
> -		kill $(cat V.pid) && wait $(cat V.pid)
> -		true"
> +		kill $(cat V.sh.pid) && wait $(cat V.sh.pid)
> +		kill $(cat V.fi.pid) && wait $(cat V.sh.pid)
> +		true'

The original interpolates the PID of the fast-import when
"when-finished" program is registered, so it is OK if somebody else
removed V.pid file; the new one interpolates when "when-finished"
program is run, reading from V.??.pid, so somebody needs to make
sure these pid files will stay around.  I do not think it is an
issue as I suspect we've left it to the global clean-up procedure
that removes the trash directory to remove the pid file.

By the way, does the second "kill && wait" wait for the right
process?

>  background_import_still_running () {
> -	if ! kill -0 "$(cat V.pid)"
> +	if ! kill -0 "$(cat V.fi.pid)"
>  	then
>  		echo >&2 "background fast-import terminated too early"
>  		false
>  	fi
>  }

  reply	other threads:[~2019-11-30 21:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-30 10:46 [PATCH] t9300-fast-import: don't hang if background fast-import exits too early SZEDER Gábor
2019-11-30 21:16 ` Junio C Hamano [this message]
2019-12-01  9:31   ` SZEDER Gábor
2019-12-01 15:38     ` Junio C Hamano
2019-12-06 19:03 ` [PATCH v2 0/2] " SZEDER Gábor
2019-12-06 19:03   ` [PATCH v2 1/2] t9300-fast-import: store the PID in a variable instead of pidfile SZEDER Gábor
2019-12-06 19:03   ` [PATCH v2 2/2] t9300-fast-import: don't hang if background fast-import exits too early SZEDER Gábor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqsgm512vl.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=szeder.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).