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

Re: misleading message for SIGFPE



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


-- 
Andreas (Kusalananda) Kähäri
Uppsala, Sweden

.




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