Skip to content
Tcl Source Code View Ticket
Login

View Ticket

fully support win32 exit codes

Closed / Accepted1267871fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2005-08-24 10:08:00
In the win32 world many people use exit codes greater 
than 8 bits. This patch preserves the Posix signal 
support in WaitPid on windows, but allows the true exit 
status to be reported.

This kind of support is essential when calling many 
systems mgmt utilities from Microsoft and others.....
matt-newmanplain2005-08-24 17:08:02
File Added - 146791: patch1
hobbsplain2005-08-25 02:05:20
Logged In: YES 
user_id=72656

Dave - you looked into this before, no?
davygrvyplain2005-08-25 12:28:16
Logged In: YES 
user_id=7549

interesting..

Doesn't Tcl_WaitPid need any modifying with this?
matt-newmanplain2005-08-25 16:16:11
Logged In: YES 
user_id=1333796

WaitPid does not need changing, because the POSIX 
macros "do the right thing" - only code that makes 
assumptions about the status without reference to the 
macros would need changing, and there is no such code in 
tcl.
The only limitation imposed on exit codes is that they can't 
set the top byte to match 0xc0 - which practically limits them 
to 24 bits. But as far as I can see that is a windows limit too.

I was able to test both the large exit code and the SEGV-
type senarios and all looks well...
patthoytsplain2005-11-03 19:39:41
Logged In: YES 
user_id=202636

It might be useful to have a test that checks the behaviour
of this patch. Applying this to the current 8.4 tip the test
suite passes in normal, symbols and thread builds so it
looks fine to me.
davygrvyplain2005-11-04 04:53:19
Logged In: YES 
user_id=7549

Pat, I don't tools at this time..  please take over. thanks.
patthoytsplain2005-11-04 18:58:52
Logged In: YES 
user_id=202636

OK - this patch doesn't seem to cause any problems but I
don't see just what it achieves either. Using a script of
'exit [lindex $argv 0]' for various values shows no
difference between 8.4.11 and the patched version. Likewise
I see no obvious differences in the result of 'exec
programreturningerrcodes' for various return values.
I need a better description of just what is being achieved
here before applying this so that we can add some tests.
matt-newmanplain2005-11-04 19:15:56
Logged In: YES 
user_id=1333796

this patch is to allow exit codes greater that 255 - try:
exit [expr { 1 << 15 }]

It is about BOTH being able to exit with such a status, but far more 
importantly it is about being able to exec a process that returns such a 
return code and being able to obtain that return code.

create exit.tcl as:
exit [expr { 1 << 15 }]

and execute:
set rc [catch { exec [info nameof] exit.tcl } err]
puts [list $rc $err $errorCode]

with vanilla 8.4 you get
0 {} {}

with the patched version you get:
1 {child process exited abnormally} {CHILDSTATUS 3152 32768}
patthoytsplain2005-11-05 05:57:34
Logged In: YES 
user_id=202636

OK. Thank you. Applied the patch plus a few tests to 8.4

Up-ported to 8.5 HEAD too. (patch attached for the record).
patthoytsplain2005-11-05 05:57:35
File Added - 155069: 1267871-exitcodes-85.patch
patthoyts Closed ticket [1267871fff]. [History diff]2005-11-05 06:06:44
patthoyts Ticket [1267871fff]: 2 changes [History diff]2005-11-05 06:06:45
Log in (anonymous is fine) to add a comment.

Attachments: