void _exit_cleanup(int code, const char *file, int line)
{
extern int keep_partial;
+ extern int log_got_error;
if (code == 0 && io_error) code = RERR_FILEIO;
if (code) log_exit(code, file, line);
+ if (code == 0) {
+ if (log_got_error) {
+ code = RERR_FILEIO;
+ }
+ }
+
exit(code);
}
}
if (*path == '/') {
- rprintf(FERROR,"ERROR: The remote path must start with a module name\n");
+ rprintf(FERROR,"ERROR: The remote path must start with a module name not a /\n");
return -1;
}
exit_cleanup(RERR_PROTOCOL);
}
- if (verbose > 2)
- rprintf(FINFO, "local_version=%d remote_version=%d\n",
- PROTOCOL_VERSION, remote_version);
-
if (remote_version >= 12) {
if (am_server) {
checksum_seed = time(NULL);
}
}
-/* some OSes have a bug where an exit causes the pending writes on
- a socket to be flushed. Do an explicit shutdown to try to prevent this */
-void io_shutdown(void)
-{
- err_list_push();
- if (multiplex_out_fd != -1) close(multiplex_out_fd);
- if (io_error_fd != -1) close(io_error_fd);
- multiplex_out_fd = -1;
- io_error_fd = -1;
-}
-
-
static void writefd(int fd,char *buf,int len)
{
stats.total_written += len;
static FILE *logfile;
static int log_error_fd = -1;
+int log_got_error=0;
struct {
int code;
while (err_list_head) {
struct err_list *el = err_list_head;
int n = write(log_error_fd, el->buf+el->written, el->len - el->written);
+ /* don't check for an error if the best way of handling the error is
+ to ignore it */
if (n == -1) break;
if (n > 0) {
el->written += n;
}
if (code == FERROR) {
+ log_got_error = 1;
f = stderr;
}
wait_process(pid, &status);
}
- return status | status2;
+ return MAX(status, status2);
}
static char *find_colon(char *s)
}
static RETSIGTYPE sigusr2_handler(int val) {
+ extern int log_got_error;
+ if (log_got_error) _exit(RERR_FILEIO);
_exit(0);
}
extern int dry_run;
extern int am_daemon;
extern int am_server;
+ int ret;
signal(SIGUSR1, sigusr1_handler);
signal(SIGUSR2, sigusr2_handler);
exit_cleanup(RERR_SYNTAX);
}
- signal(SIGCHLD,SIG_IGN);
signal(SIGINT,SIGNAL_CAST sig_int);
signal(SIGPIPE,SIGNAL_CAST sig_int);
signal(SIGHUP,SIGNAL_CAST sig_int);
start_server(STDIN_FILENO, STDOUT_FILENO, argc, argv);
}
- return start_client(argc, argv);
+ ret = start_client(argc, argv);
+ exit_cleanup(ret);
+ return ret;
}