diff --git a/libguile/posix.c b/libguile/posix.c index b4612ed13..7b18024ad 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1611,7 +1611,7 @@ SCM_DEFINE (scm_gethostname, "gethostname", 0, 0, 0, { /* 256 is for Solaris, under Linux ENAMETOOLONG is returned if not large enough. */ - int len = 256, res; + int len = 256, res, save_errno; char *p = scm_must_malloc (len, "gethostname"); SCM name; @@ -1624,7 +1624,9 @@ SCM_DEFINE (scm_gethostname, "gethostname", 0, 0, 0, } if (res == -1) { + save_errno = errno; scm_must_free (p); + errno = save_errno; SCM_SYSERROR; } name = scm_makfrom0str (p);