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

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

From
Johannes Sixt <j6t@kdbg.org>
Date
Dec 31, 2009, 16:22 UTC
Message-ID
<4B3CCFAA.7060702@kdbg.org>
In-Reply-To
<1262256488-22985-2-git-send-email-ilari.liusvaara@elisanet.fi>
Ilari Liusvaara schrieb:
Show 14 quoted lines
> +static inline void force_close(int fd)
> +{
> +	int err = 0;
> +	/*
> +	 * Retry EINTRs undefinitely, exit on EBADF immediately, other
> +	 * errors retry only up to three times (even if pipe close
> +	 * shouldn't cause other errors, but you never know with
> +	 * what broken systems may return on closed file descriptor).
> +	 * consequences of failure to close pipe here may include
> +	 * deadlocking.
> +	 */
> +	while (close(fd) < 0 && errno != EBADF && err < 3)
> +		if(errno != EINTR)
> +			err++;

What's the point to iterate on all errors except EBADF? If the close() fails once, it will fail again.

Show 8 quoted lines
> +			/*
> +			 * Clean up the process that did the failed execution
> +			 * so no zombies remain.
> +			 */
> +wait_again:
> +			r = waitpid(cmd->pid, &ret, 0);
> +			if (r < 0 && errno != ECHILD)
> +				goto wait_again;
You really should iterate only on well-known errors. What's wrong with
		while (waitpid(pid, &status, 0) < 0 && errno == EINTR)
			;	/* nothing */
similar to wait_or_whine()'s call to waitpid() and to avoid goto.
Show 20 quoted lines
> +int main(int argc, char **argv)
> +{
> +	char* procs[2];
> +	struct child_process proc;
> +	memset(&proc, 0, sizeof(proc));
> +
> +	if(argc < 2)
> +		return 1;
> +
> +	if (argv[1][1] == '1')
> +		procs[0] = "does-not-exist-62896869286";
> +	procs[1] = NULL;
> +	proc.argv = (const char **)procs;
> +
> +	if (!run_command(&proc))
> +		return 1;
> +	if (errno != ENOENT)
> +		return 1;
> +	return 0;
> +}

This test is not specific enough: It would pass even without your change to start_command(), because finish_command() detects the ENOENT case. You really want to test that you see ENOENT after start_command() (i.e., before finish_command()).

-- Hannes
Previous: Ilari LiusvaaraNext: Ilari Liusvaara
Message 3 of 4 in “Improve remote helper exec failure reporting”
  1. 0/2 Improve remote helper 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. 2/2 Improve transport helper exec failure reportingIlari Liusvaara, Dec 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.