Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Errorlevel on Win32 with EXEC

Closed616527ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2002-09-30 13:11:15
Not shure, if this is the right category. The third
word of $errorCode gives the returncode (the
"errorlevel" in M$-terminology). In Win32, this is a
16bit-Field (in old MSDOS-Days it was a BYTE).
errorCode only holds the low-byte, it seems. Is this a
bug or intended?
dgpplain2002-09-30 21:02:54
Logged In: YES 
user_id=80530

An [exec] creates a "pipe" channel, so it's really a channel
type
issue.  Not obvious, I know.  You can check TIP 16 for details.
davygrvyplain2002-11-28 06:21:45
Logged In: YES 
user_id=7549

Eventhough GetExitCode(hProcess, &dwCode) returns a 
DWORD, for cross-platformness one should be limited to 0-
127 only, IIRC.
davygrvyplain2002-12-08 22:48:27
Logged In: YES 
user_id=7549

From Tcl_WaitPid() in win/tclWinPipe.c:

    *statPtr = ((exitCode << 8) & 0xff00);

all we get is a byte range.  Yes, it looks odd by shifting left 
and truncating, but this is for the WEXITSTATUS() macro 
back in TclCleanupChildren() in generic/tclPipe.c

I have some additional code i'm playing with to enable 
Tcl_WaitPid() to return exit exception codes.  It looks like 
this, but isn't ready for a commit just yet:

if (exitCode & 0xC0000000) {
    /*
     * A fatal exception occured.
     */
    switch (exitCode) {
case EXCEPTION_INT_OVERFLOW:
    *statPtr = SIGFPE;
    break;
....
    }
} else {
    /*
     * Non exception, normal, exit code.  Note that 
the exit code
     * is truncated to a byte range.
     */
    *statPtr = ((exitCode << 8) & 0xff00);
}
davygrvyplain2003-01-24 16:11:51
Logged In: YES 
user_id=7549

This bug should be closed. exit codes are only within a BYTE 
range.
davygrvyplain2003-02-15 03:24:01
Logged In: YES 
user_id=7549

0-255 is the range and is built into the WEXITSTATUS() 
macro.
Log in (anonymous is fine) to add a comment.