From 334b8d5be7a85155b1e904bbca4140a4a5f50f8a Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Tue, 13 Dec 2011 07:40:37 +0000 Subject: [PATCH] Mark channel closed before interrupting in Unix's OS_channel_closed. Interruption may restart the primitive that called it, which will choke on a bad file descriptor. --- src/microcode/uxio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/microcode/uxio.c b/src/microcode/uxio.c index 353620709..729f009f3 100644 --- a/src/microcode/uxio.c +++ b/src/microcode/uxio.c @@ -124,13 +124,14 @@ OS_channel_close (Tchannel channel) { if (! (CHANNEL_INTERNAL (channel))) { - if (0 > (UX_close (CHANNEL_DESCRIPTOR (channel)))) + int status = (UX_close (CHANNEL_DESCRIPTOR (channel))); + MARK_CHANNEL_CLOSED (channel); + if (status < 0) switch (errno) { case EINTR: deliver_pending_interrupts (); break; case EBADF: error_system_call (errno, syscall_close); break; } - MARK_CHANNEL_CLOSED (channel); } } -- 2.25.1