[prev in list] [next in list] [prev in thread] [next in thread]
List: git
Subject: Re: [updated patch v3 1/2] Report exec errors from run-command
From: Johannes Sixt <j6t () kdbg ! org>
Date: 2009-12-31 19:03:04
Message-ID: 4B3CF568.1050705 () kdbg ! org
[Download RAW message or body]
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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic