Mercurial > illumos > illumos-gate
changeset 13853:93ee8890b568
72 _tx_error needs to preserve the errno value it is supposed to display
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Richard Lowe <richlowe@richlowe.net>
author | Gary Mills <gary_mills@fastmail.fm> |
---|---|
date | Sat, 13 Oct 2012 10:17:57 -0500 |
parents | dc1b5bc72558 |
children | 095969cfa779 |
files | usr/src/lib/libnsl/nsl/t_error.c |
diffstat | 1 files changed, 9 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/lib/libnsl/nsl/t_error.c Mon Oct 01 18:01:32 2012 -0700 +++ b/usr/src/lib/libnsl/nsl/t_error.c Sat Oct 13 10:17:57 2012 -0500 @@ -26,10 +26,9 @@ /* * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * Copyright (c) 2012 Gary Mills */ -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */ - #include "mt.h" #include <xti.h> #include <errno.h> @@ -42,21 +41,19 @@ _tx_error(const char *s, int api_semantics) { const char *c; - int n; + int errnum = errno; /* In case a system call fails. */ c = t_strerror(t_errno); if (s != NULL && *s != '\0') { - n = strlen(s); - if (n) { - (void) write(2, s, (unsigned)n); - (void) write(2, ": ", 2); - } + (void) write(2, s, strlen(s)); + (void) write(2, ": ", 2); } - (void) write(2, c, (unsigned)strlen(c)); + (void) write(2, c, strlen(c)); if (t_errno == TSYSERR) { + c = strerror(errnum); (void) write(2, ": ", 2); - perror(""); - } else - (void) write(2, "\n", 1); + (void) write(2, c, strlen(c)); + } + (void) write(2, "\n", 1); return (0); }