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

Re: [updated patch v3 1/2] Report exec errors from run-command

From
Johannes Sixt <j6t@kdbg.org>
Date
Dec 31, 2009, 19:03 UTC
Message-ID
<4B3CF568.1050705@kdbg.org>
In-Reply-To
<1262284003-1417-2-git-send-email-ilari.liusvaara@elisanet.fi>
Ilari Liusvaara schrieb:
Show 10 quoted lines
> +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?

Show 28 quoted lines
>  	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
Previous: Ilari LiusvaaraNext: Junio C Hamano
Message 3 of 6 in “Imporve remote helpers exec failure reporting”
  1. 0/2 Imporve remote helpers exec failure reportingIlari Liusvaara, Dec 31, 2009
  2. 1/2 Report exec errors from run-commandIlari Liusvaara, Dec 31, 2009
  3. Johannes SixtDec 31, 2009
  4. Junio C HamanoJan 5, 2010
  5. 2/2 Improve transport helper exec failure reportingIlari Liusvaara, Dec 31, 2009
  6. Johannes SixtDec 31, 2009

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.