Print this page
72 _tx_error needs to preserve the errno value it is supposed to display

*** 24,37 **** /* All Rights Reserved */ /* * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ - #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */ - #include "mt.h" #include <xti.h> #include <errno.h> #include <unistd.h> #include <stdio.h> --- 24,36 ---- /* All Rights Reserved */ /* * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * Copyright (c) 2012 Gary Mills */ #include "mt.h" #include <xti.h> #include <errno.h> #include <unistd.h> #include <stdio.h>
*** 40,62 **** /* ARGSUSED1 */ int _tx_error(const char *s, int api_semantics) { const char *c; ! int n; 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, c, (unsigned)strlen(c)); if (t_errno == TSYSERR) { (void) write(2, ": ", 2); ! perror(""); ! } else (void) write(2, "\n", 1); return (0); } --- 39,59 ---- /* ARGSUSED1 */ int _tx_error(const char *s, int api_semantics) { const char *c; ! int errnum = errno; /* In case a system call fails. */ c = t_strerror(t_errno); if (s != NULL && *s != '\0') { ! (void) write(2, s, (unsigned)strlen(s)); (void) write(2, ": ", 2); } (void) write(2, c, (unsigned)strlen(c)); if (t_errno == TSYSERR) { + c = strerror(errnum); (void) write(2, ": ", 2); ! (void) write(2, c, (unsigned)strlen(c)); ! } (void) write(2, "\n", 1); return (0); }