From 9d00cfc02bcbdcebdf094026b352df5c01156768 Mon Sep 17 00:00:00 2001 From: mirabilos Date: Sun, 2 Apr 2017 16:42:44 +0200 Subject: [PATCH] fix two small setmode()-related bugs --- funcs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/funcs.c b/funcs.c index 26e0494..12eaa96 100644 --- a/funcs.c +++ b/funcs.c @@ -1971,6 +1971,7 @@ c_read(const char **wp) #endif #if defined(__OS2__) && defined(MKSH_WITH_TEXTMODE) int saved_mode; + int saved_errno; #endif while ((c = ksh_getopt(wp, &builtin_opt, c_read_opts)) != -1) @@ -2105,7 +2106,9 @@ c_read(const char **wp) #endif if ((bytesread = blocking_read(fd, xp, bytesleft)) == (size_t)-1) { #if defined(__OS2__) && defined(MKSH_WITH_TEXTMODE) + saved_errno = errno; setmode(fd, saved_mode); + errno = saved_errno; #endif if (errno == EINTR) { /* check whether the signal would normally kill */ @@ -2840,7 +2843,7 @@ c_exec(const char **wp MKSH_A_UNUSED) return (0); } -#if HAVE_MKNOD +#if HAVE_MKNOD && !defined(__OS2__) int c_mknod(const char **wp) {