1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-24 06:25:03 -05:00

Merge pterm process-exit fix from 'pre-0.77'.

This commit is contained in:
Simon Tatham 2022-03-08 18:06:13 +00:00
commit 5243a2395a

View File

@ -356,13 +356,27 @@ static int conpty_exitcode(Backend *be)
{ {
ConPTY *conpty = container_of(be, ConPTY, backend); ConPTY *conpty = container_of(be, ConPTY, backend);
if (conpty->exited && if (conpty->exited) {
0 <= conpty->exitstatus && /*
conpty->exitstatus <= INT_MAX) * PuTTY's representation of exit statuses expects them to be
return conpty->exitstatus; * non-negative 'int' values. But Windows exit statuses can
else * include all those exception codes like 0xC000001D which
* convert to negative 32-bit ints.
*
* I don't think there's a great deal of use for returning
* those in full detail, right now. (Though if we ever
* connected this system up to a Windows version of psusan or
* Uppity, perhaps there might be?)
*
* So we clip them at INT_MAX-1, since INT_MAX is reserved for
* 'exit so unclean as to inhibit Close On Clean Exit'.
*/
return (0 <= conpty->exitstatus && conpty->exitstatus < INT_MAX) ?
conpty->exitstatus : INT_MAX-1;
} else {
return -1; return -1;
} }
}
static int conpty_cfg_info(Backend *be) static int conpty_cfg_info(Backend *be)
{ {