# HG changeset patch # User Gary Mills # Date 1350141477 18000 # Node ID 93ee8890b5681c8623d46443ae53d50d1c514bce # Parent dc1b5bc72558586928d84492b35570ca852d0cef 72 _tx_error needs to preserve the errno value it is supposed to display Reviewed by: Garrett D'Amore Approved by: Richard Lowe diff -r dc1b5bc72558 -r 93ee8890b568 usr/src/lib/libnsl/nsl/t_error.c --- 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 #include @@ -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); }