PATCH: don't leave core behind on distant machine

Marc Espie
Sat, 14 Dec 2002 18:34:01 -0000

I've noticed that
rsync -e ssh network:some
^C

would tend to leave cores behind on the distand machine.

Turns out rsync was trying to log a final error message... which could
not get written to stderr... which got detected by rwrite... which called
exit_cleanup... which in turn tried to write to stderr....... until all
stack got eaten up.

This patch fixes the infinite recursion.

--- cleanup.c.orig	Sat Dec 14 18:55:23 2002
+++ cleanup.c	Sat Dec 14 18:55:55 2002
@@ -43,6 +43,12 @@ void _exit_cleanup(int code, const char
 	int ocode = code;
 	extern int keep_partial;
 	extern int log_got_error;
+	static int in_cleanup = 0;
+
+	/* forbid recursive calls */
+	if (in_cleanup)
+		return;
+	in_cleanup = 1;

 	signal(SIGUSR1, SIG_IGN);
 	signal(SIGUSR2, SIG_IGN);