summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixSock.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tclUnixSock.c')
-rw-r--r--unix/tclUnixSock.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index f72a888..a90a72f 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -624,12 +624,11 @@ TcpOutputProc(
static int
TcpCloseProc(
void *instanceData, /* The socket to close. */
- Tcl_Interp *dummy) /* For error reporting - unused. */
+ Tcl_Interp *interp) /* For error reporting */
{
TcpState *statePtr = (TcpState *)instanceData;
int errorCode = 0;
TcpFdList *fds;
- (void)dummy;
/*
* Delete a file handler that may be active for this socket if this is a
@@ -663,6 +662,9 @@ TcpCloseProc(
freeaddrinfo(statePtr->myaddrlist);
}
Tcl_Free(statePtr);
+ if (interp && errorCode) {
+ Tcl_SetResult(interp, (char *)Tcl_PosixError(interp), TCL_STATIC);
+ }
return errorCode;
}
@@ -692,6 +694,7 @@ TcpClose2Proc(
TcpState *statePtr = (TcpState *)instanceData;
int readError = 0;
int writeError = 0;
+ int errorCode = 0;
/*
* Shutdown the OS socket handle.
@@ -705,7 +708,12 @@ TcpClose2Proc(
if ((flags & TCL_CLOSE_WRITE) && (shutdown(statePtr->fds.fd, SHUT_WR) < 0)) {
writeError = errno;
}
- return (readError != 0) ? readError : writeError;
+
+ errorCode = (readError != 0) ? readError : writeError;
+ if (interp && errorCode) {
+ Tcl_SetResult(interp, (char *)Tcl_PosixError(interp), TCL_STATIC);
+ }
+ return errorCode;
}
/*