Re: [updated patch v3 1/2] Report exec errors from run-command
From: Johannes Sixt <hidden>
Date: 2016-06-15 22:47:57
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