public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Johannes Sixt <j6t@kdbg•org>
To: Ilari Liusvaara <ilari.liusvaara@elisanet•fi>
Cc: git@vger•kernel.org
Subject: Re: [updated patch v3 1/2] Report exec errors from run-command
Date: Thu, 31 Dec 2009 20:03:04 +0100	[thread overview]
Message-ID: <4B3CF568.1050705@kdbg.org> (raw)
In-Reply-To: <1262284003-1417-2-git-send-email-ilari.liusvaara@elisanet.fi>

Ilari Liusvaara schrieb:
> +static inline void force_close(int fd)
> +{
> +	/*
> +	 * The close is deemed success or failed in non-transient way if
> +	 * close() suceeds, returns EBADF or error other than EINTR or
> +	 * EAGAIN.
> +	 */
> +	while (close(fd) < 0 && errno != EBADF)
> +		if(errno != EINTR && errno != EAGAIN)
> +			break;

You are constantly ignoring proposals to iterate only on EINTR and EAGAIN, 
but do not make an argument why you do otherwise. Did I miss something?

>  	cmd->pid = fork();
> -	if (!cmd->pid) {
> +	if (cmd->pid > 0) {
> +		int r = 0, ret;
> +		force_close(report_pipe[1]);
> +read_again:
> +		if (report_pipe[0] >= 0)
> +			r = read(report_pipe[0], &ret, sizeof(ret));
> +		if (r < 0 && (errno == EAGAIN || errno == EINTR ||
> +			errno == EWOULDBLOCK))
> +			goto read_again;
> +		else if (r < 0)
> +			warning("Can't read exec status report: %s\n",
> +				strerror(errno));
> +		else if (r == 0)
> +			;
> +		else if (r < sizeof(ret)) {
> +			warning("Received incomplete exec status report.\n");
> +			errno = EBADMSG;
> +		} else {
> +			failed_errno = ret;
> +			/*
> +			 * Clean up the process that did the failed execution
> +			 * so no zombies remain.
> +			 */
> +			if(waitpid(cmd->pid, &ret, 0) < 0 && errno == EINTR)
> +				/* Nothing. */ ;
> +			cmd->pid = -1;

As per Documentation/technical/api-run-command.txt, you should write an 
error here, except if (failed_errno==ENOENT && cmd->silent_exec_failure!=0).

> +test_expect_success "reporting ENOENT" \
> +"test-run-command 1"

I wonder what this parameter "1" is good for...

-- Hannes

  reply	other threads:[~2009-12-31 19:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-31 18:26 [updated patch v3 0/2] Imporve remote helpers exec failure reporting Ilari Liusvaara
2009-12-31 18:26 ` [updated patch v3 1/2] Report exec errors from run-command Ilari Liusvaara
2009-12-31 19:03   ` Johannes Sixt [this message]
2010-01-05  5:11     ` Junio C Hamano
2009-12-31 18:26 ` [updated patch v3 2/2] Improve transport helper exec failure reporting Ilari Liusvaara
2009-12-31 19:05   ` Johannes Sixt

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

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

  git send-email \
    --in-reply-to=4B3CF568.1050705@kdbg.org \
    --to=j6t@kdbg$(echo .)org \
    --cc=git@vger$(echo .)kernel.org \
    --cc=ilari.liusvaara@elisanet$(echo .)fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox