Discussion:
[ast-users] About "exit 267"
Paulo César Pereira de Andrade
2016-09-28 16:31:47 UTC
Permalink
Hi,

I cannot find the reason of this chunk in
src/cmd/ksh93/bltins/cflow.c when diff'ing
ksh-20100621 and ksh-20120801

The problem is that if one calls:

$ exit 267

ksh will pretend it did sigsegv. It will happen for
other signals as well, for example:

$ ksh
$ exit 286
Power failure

$ ksh
$ exit 273
<< sets SIGCHLD to SIG_DFL and calls pause >>

Is this an intended feature?

Thanks,
Paulo
Richard Hamilton
2016-09-28 17:10:29 UTC
Permalink
Given the description of wait(2), only exit codes 0-255 will be fully
available to the parent. Higher values may act oddly, although I'd suppose
it's the application (ksh, in this case) rather than the OS that's
responsible for such strange results.

What I see about the exit builtin command in the ksh man page that's
relevant is:

The value of a simple-command is its exit status; 0-255 if
it terminates normally; 256+signum if it terminates abnormally
(the
name of the signal corresponding to the exit status can be obtained
via
the -l option of the kill built-in utility).

and

- exit [ n ]
Causes the shell to exit with the exit status specified by
n.
The value will be the least significant 8 bits of the
specified
status. If n is omitted, then the exit status is that of
the
last command executed. An end-of-file will also cause the
shell
to exit except for a shell which has the ignoreeof option
(see
set below) turned on.

In your case, it seems to me that it is NOT properly masking off the value
given to the exit command, so that only the low 8 bits are acted on and
made available to the parent.


On Wed, Sep 28, 2016 at 12:31 PM, Paulo César Pereira de Andrade <
Post by Paulo César Pereira de Andrade
Hi,
I cannot find the reason of this chunk in
src/cmd/ksh93/bltins/cflow.c when diff'ing
ksh-20100621 and ksh-20120801
$ exit 267
ksh will pretend it did sigsegv. It will happen for
$ ksh
$ exit 286
Power failure
$ ksh
$ exit 273
<< sets SIGCHLD to SIG_DFL and calls pause >>
Is this an intended feature?
Thanks,
Paulo
_______________________________________________
ast-users mailing list
http://lists.research.att.com/mailman/listinfo/ast-users
Paulo César Pereira de Andrade
2016-09-28 17:44:33 UTC
Permalink
Post by Richard Hamilton
Given the description of wait(2), only exit codes 0-255 will be fully
available to the parent. Higher values may act oddly, although I'd suppose
it's the application (ksh, in this case) rather than the OS that's
responsible for such strange results.
What I see about the exit builtin command in the ksh man page that's
The value of a simple-command is its exit status; 0-255 if
it terminates normally; 256+signum if it terminates abnormally
(the
name of the signal corresponding to the exit status can be obtained
via
the -l option of the kill built-in utility).
and
- exit [ n ]
Causes the shell to exit with the exit status specified by
n.
The value will be the least significant 8 bits of the
specified
Indeed. I added some extra information about it at:

https://bugzilla.redhat.com/show_bug.cgi?id=1369571
Post by Richard Hamilton
status. If n is omitted, then the exit status is that of
the
last command executed. An end-of-file will also cause the
shell
to exit except for a shell which has the ignoreeof option
(see
set below) turned on.
In your case, it seems to me that it is NOT properly masking off the value
given to the exit command, so that only the low 8 bits are acted on and made
available to the parent.
Thanks!
Paulo

Loading...