? 1267871-exitcodes-85.patch
? 1267871-exitcodes.patch.txt
? binary_u.patch
Index: generic/tclPipe.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclPipe.c,v
retrieving revision 1.14
diff -u -r1.14 tclPipe.c
--- generic/tclPipe.c	2 Nov 2005 14:51:05 -0000	1.14
+++ generic/tclPipe.c	4 Nov 2005 22:36:20 -0000
@@ -317,7 +317,7 @@
 	    sprintf(msg1, "%lu", resolvedPid);
 	    if (WIFEXITED(waitStatus)) {
                 if (interp != (Tcl_Interp *) NULL) {
-		    sprintf(msg2, "%hu", WEXITSTATUS(waitStatus));
+		    sprintf(msg2, "%lu", WEXITSTATUS(waitStatus));
                     Tcl_SetErrorCode(interp, "CHILDSTATUS", msg1, msg2, NULL);
                 }
 		abnormalExit = 1;
Index: tests/exec.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/exec.test,v
retrieving revision 1.23
diff -u -r1.23 exec.test
--- tests/exec.test	28 Jul 2005 10:55:37 -0000	1.23
+++ tests/exec.test	4 Nov 2005 22:24:46 -0000
@@ -485,6 +485,51 @@
 	    [string tolower [lrange $errorCode 2 end]]
 } {1 {couldn't execute "_weird_cmd_": no such file or directory} POSIX {{no such file or directory}}}
 
+test exec-13.4 {extended exit result codes} {
+    -constraints {win}
+    -setup {
+        set tmp [makeFile {exit 0x00000101} tmpfile.exec-13.4]
+    }
+    -body {
+        list [catch {exec [interpreter] $tmp} err]\
+            [lreplace $::errorCode 1 1 {}]
+    }
+    -cleanup {
+        removeFile $tmp
+    }
+    -result {1 {CHILDSTATUS {} 257}}
+}
+
+test exec-13.5 {extended exit result codes: max value} {
+    -constraints {win}
+    -setup {
+        set tmp [makeFile {exit 0x3fffffff} tmpfile.exec-13.5]
+    }
+    -body {
+        list [catch {exec [interpreter] $tmp} err]\
+            [lreplace $::errorCode 1 1 {}]
+    }
+    -cleanup {
+        removeFile $tmp
+    }
+    -result {1 {CHILDSTATUS {} 1073741823}}
+}
+
+test exec-13.6 {extended exit result codes: signalled} {   
+    -constraints {win}
+    -setup {
+        set tmp [makeFile {exit 0xC0000016} tmpfile.exec-13.6]
+    }
+    -body {
+        list [catch {exec [interpreter] $tmp} err]\
+            [lreplace $::errorCode 1 1 {}]
+    }
+    -cleanup {
+        removeFile $tmp
+    }
+    -result {1 {CHILDKILLED {} SIGABRT SIGABRT}}
+}
+
 # Switches before the first argument
 
 test exec-14.1 {-keepnewline switch} {exec} {
Index: win/tclWinPipe.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinPipe.c,v
retrieving revision 1.60
diff -u -r1.60 tclWinPipe.c
--- win/tclWinPipe.c	4 Nov 2005 00:06:50 -0000	1.60
+++ win/tclWinPipe.c	4 Nov 2005 18:47:23 -0000
@@ -2579,12 +2579,12 @@
 	case EXCEPTION_FLT_UNDERFLOW:
 	case EXCEPTION_INT_DIVIDE_BY_ZERO:
 	case EXCEPTION_INT_OVERFLOW:
-	    *statPtr = SIGFPE;
+	    *statPtr = 0xC0000000 | SIGFPE;
 	    break;
 
 	case EXCEPTION_PRIV_INSTRUCTION:
 	case EXCEPTION_ILLEGAL_INSTRUCTION:
-	    *statPtr = SIGILL;
+	    *statPtr = 0xC0000000 | SIGILL;
 	    break;
 
 	case EXCEPTION_ACCESS_VIOLATION:
@@ -2594,20 +2594,20 @@
 	case EXCEPTION_INVALID_DISPOSITION:
 	case EXCEPTION_GUARD_PAGE:
 	case EXCEPTION_INVALID_HANDLE:
-	    *statPtr = SIGSEGV;
+	    *statPtr = 0xC0000000 | SIGSEGV;
 	    break;
 
 	case EXCEPTION_DATATYPE_MISALIGNMENT:
-	    *statPtr = SIGBUS;
+	    *statPtr = 0xC0000000 | SIGBUS;
 	    break;
 
 	case EXCEPTION_BREAKPOINT:
 	case EXCEPTION_SINGLE_STEP:
-	    *statPtr = SIGTRAP;
+	    *statPtr = 0xC0000000 | SIGTRAP;
 	    break;
 
 	case CONTROL_C_EXIT:
-	    *statPtr = SIGINT;
+	    *statPtr = 0xC0000000 | SIGINT;
 	    break;
 
 	default:
@@ -2622,13 +2622,13 @@
 	     * truncating it.
 	     */
 
-	    *statPtr = (((int)(short) exitCode << 8) & 0xffff00);
+	    *statPtr = exitCode;
 	    break;
 	}
 	result = pid;
     } else {
 	errno = ECHILD;
-	*statPtr = ECHILD;
+	*statPtr = 0xC0000000 | ECHILD;
 	result = (Tcl_Pid) -1;
     }
 
Index: win/tclWinPort.h
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinPort.h,v
retrieving revision 1.46
diff -u -r1.46 tclWinPort.h
--- win/tclWinPort.h	3 Nov 2005 00:17:31 -0000	1.46
+++ win/tclWinPort.h	4 Nov 2005 18:44:01 -0000
@@ -240,15 +240,15 @@
 #endif /* TCL_UNION_WAIT */
 
 #ifndef WIFEXITED
-#   define WIFEXITED(stat)  (((*((int *) &(stat))) & 0xff) == 0)
+#   define WIFEXITED(stat)  (((*((int *) &(stat))) & 0xC0000000) == 0)
 #endif
 
 #ifndef WEXITSTATUS
-#   define WEXITSTATUS(stat) (short)(((*((int *) &(stat))) >> 8) & 0xffff)
+#   define WEXITSTATUS(stat) (*((int *) &(stat)))
 #endif
 
 #ifndef WIFSIGNALED
-#   define WIFSIGNALED(stat) (((*((int *) &(stat)))) && ((*((int *) &(stat))) == ((*((int *) &(stat))) & 0x00ff)))
+#   define WIFSIGNALED(stat) ((*((int *) &(stat))) & 0xC0000000)
 #endif
 
 #ifndef WTERMSIG
@@ -256,7 +256,7 @@
 #endif
 
 #ifndef WIFSTOPPED
-#   define WIFSTOPPED(stat)  (((*((int *) &(stat))) & 0xff) == 0177)
+#   define WIFSTOPPED(stat)  0
 #endif
 
 #ifndef WSTOPSIG
