Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: misleading message for SIGFPE



On 2024-09-24 15:09:37 +0200, Andreas Kähäri wrote:
> On Tue, Sep 24, 2024 at 02:36:52PM +0200, Vincent Lefevre wrote:
> > When a command is terminated by SIGFPE, I get a message saying
> > "floating point exception" (this comes from Src/signames.c):
> > 
> > qaa% sh -c 'kill -FPE $$'
> > zsh: floating point exception (core dumped)  sh -c 'kill -FPE $$'
> > 
> > However, a SIGFPE may also be generated by integer operations
> > (such as 1 / 0).
> > 
> > ISO C and POSIX use the term "erroneous arithmetic operation".
> > The GNU C Library manual says "fatal arithmetic error".
> > 
> > BTW, in addition to the signal description, I would suggest to
> > output the signal name, e.g.
> > 
> > SIGFPE - erroneous arithmetic operation (core dumped)
> > SIGSEGV - segmentation fault (core dumped)
> > SIGKILL - killed
> > 
> > Otherwise it is not clear that the command termination is due to
> > a signal (even though the exit status can be checked / reported).
> 
> Isn't it already clear from the value of $? what the signal was?
> 
> 	$ sh -c 'kill -FPE $$'
> 	zsh: floating point exception  sh -c 'kill -FPE $$'
> 	$ echo $?
> 	136
> 
> 	$ kill -l 136
> 	FPE

This requires another step. The idea would be to have it in the
error message. This could be useful in bug reports, like here:

https://github.com/pytorch/pytorch/issues/89817

You cannot go back in time to get the $? value.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Messages sorted by: Reverse Date, Date, Thread, Author