On Fri, Sep 23, 2005 at 05:26:41PM +0800, David Schulz wrote: > rsync error: unexplained error (code -4169475) at main.c(692)
The code returned at main.c line 692 came from the wait_process() function, which called WEXITSTATUS() on a value returned by waitpid(). One thing I noticed that was wrong is that rsync did not check the value of WIFEXITED() first. Also, if waitpid() returned -1, the value would be bogus. Attached is a patch that should fix these problems. See if it makes the error code turn into a defined value. I chose to use (for the moment) some existing RERR_* values for the case where the command was killed by a signal (125) or core-dumped (124). In the CVS version, I'll actually define some new return values for these cases. ..wayne..
--- main.c 16 Sep 2005 16:40:30 -0000 1.277 +++ main.c 26 Sep 2005 16:48:28 -0000 @@ -81,12 +81,12 @@ static void show_malloc_stats(void); /**************************************************************************** wait for a process to exit, calling io_flush while waiting ****************************************************************************/ -void wait_process(pid_t pid, int *status) +void wait_process(pid_t pid, int *code_ptr) { pid_t waited_pid; - int cnt; + int cnt, status; - while ((waited_pid = waitpid(pid, status, WNOHANG)) == 0) { + while ((waited_pid = waitpid(pid, &status, WNOHANG)) == 0) { msleep(20); io_flush(FULL_FLUSH); } @@ -97,7 +100,8 @@ void wait_process(pid_t pid, int *status */ for (cnt = 0; cnt < MAXCHILDPROCS; cnt++) { if (pid == pid_stat_table[cnt].pid) { - *status = pid_stat_table[cnt].status; + waited_pid = pid; + status = pid_stat_table[cnt].status; pid_stat_table[cnt].pid = 0; break; } @@ -107,9 +111,18 @@ void wait_process(pid_t pid, int *status /* TODO: If the child exited on a signal, then log an * appropriate error message. Perhaps we should also accept a * message describing the purpose of the child. Also indicate - * this to the caller so that thhey know something went - * wrong. */ - *status = WEXITSTATUS(*status); + * this to the caller so that they know something went wrong. */ + if (waited_pid < 0) + *code_ptr = RERR_WAITCHILD; + else if (!WIFEXITED(status)) { + if (WCOREDUMP(status)) + *code_ptr = RERR_CMD_FAILED; + else if (WIFSIGNALED(status)) + *code_ptr = RERR_CMD_KILLED; + else + *code_ptr = RERR_WAITCHILD; + } else + *code_ptr = WEXITSTATUS(status); } /* This function gets called from all 3 processes. We want the client side
-- To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html