[Ecls-list] Patch: print errno in ecl_internal_error()

Josh Elsasser josh at elsasser.org
Sun Jan 25 15:34:45 UTC 2009

On Sun, Jan 25, 2009 at 10:06:30AM -0500, Geo Carncross wrote:
> You'll need to save errno first as printf() can clobber it. Also, strerror()
> can modify errno as well.

You're right, I wasn't thinking. Here's an improved patch:

diff --git src/c/error.d src/c/error.d
index 0214de3..9c88dc8 100644
--- src/c/error.d
+++ src/c/error.d
@@ -29,7 +29,10 @@
 ecl_internal_error(const char *s)
+	int saved_errno = errno;
 	printf("\nInternal or unrecoverable error in:\n%s\n", s);
+	if (saved_errno)
+		printf("  [%d: %s]\n", saved_errno, strerror(saved_errno));
 #ifdef SIGIOT
 	signal(SIGIOT, SIG_DFL); /* avoid getting into a loop with abort */

More information about the ecl-devel mailing list