* Truncated fatal error messages
@ 2012-09-22 8:08 Eli Zaretskii
2012-09-22 8:22 ` Andreas Schwab
2012-09-22 8:24 ` Paul Eggert
0 siblings, 2 replies; 3+ messages in thread
From: Eli Zaretskii @ 2012-09-22 8:08 UTC (permalink / raw
To: Paul Eggert; +Cc: emacs-devel
This change:
@@ -2012,7 +2014,12 @@ shut_down_emacs (int sig, Lisp_Object st
{
reset_all_sys_modes ();
if (sig && sig != SIGTERM)
- fprintf (stderr, "Fatal error %d: %s", sig, strsignal (sig));
+ {
+ char buf[100];
+ int buflen = snprintf (buf, sizeof buf, "Fatal error %d: %s",
+ sig, strsignal (sig));
+ ignore_value (write (STDERR_FILENO, buf, buflen));
+ }
}
}
#else
arbitrarily limits the signal description due to the 99-char limit of
the buffer. Isn't it better to allocate the buffer (with alloca)
based on the length of the signal description?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Truncated fatal error messages
2012-09-22 8:08 Truncated fatal error messages Eli Zaretskii
@ 2012-09-22 8:22 ` Andreas Schwab
2012-09-22 8:24 ` Paul Eggert
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2012-09-22 8:22 UTC (permalink / raw
To: Eli Zaretskii; +Cc: Paul Eggert, emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
> This change:
>
> @@ -2012,7 +2014,12 @@ shut_down_emacs (int sig, Lisp_Object st
> {
> reset_all_sys_modes ();
> if (sig && sig != SIGTERM)
> - fprintf (stderr, "Fatal error %d: %s", sig, strsignal (sig));
> + {
> + char buf[100];
> + int buflen = snprintf (buf, sizeof buf, "Fatal error %d: %s",
> + sig, strsignal (sig));
> + ignore_value (write (STDERR_FILENO, buf, buflen));
> + }
> }
> }
> #else
>
> arbitrarily limits the signal description due to the 99-char limit of
> the buffer. Isn't it better to allocate the buffer (with alloca)
> based on the length of the signal description?
There is no need to copy the signal description in the buffer at all.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Truncated fatal error messages
2012-09-22 8:08 Truncated fatal error messages Eli Zaretskii
2012-09-22 8:22 ` Andreas Schwab
@ 2012-09-22 8:24 ` Paul Eggert
1 sibling, 0 replies; 3+ messages in thread
From: Paul Eggert @ 2012-09-22 8:24 UTC (permalink / raw
To: Eli Zaretskii; +Cc: emacs-devel
On 09/22/2012 01:08 AM, Eli Zaretskii wrote:
> Isn't it better to allocate the buffer (with alloca)
If we're worried about arbitrarily long output of strsignal,
alloca won't work, since alloca can't go over a few
kilobytes. And we can't use malloc here, since signal
handlers can't malloc.
In practice I expect the old code was fine, since signal
descriptions are never that long. But since the issue has
been raised, I modified the code to avoid the need to allocate
an arbitrarily long buffer.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-09-22 8:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-22 8:08 Truncated fatal error messages Eli Zaretskii
2012-09-22 8:22 ` Andreas Schwab
2012-09-22 8:24 ` Paul Eggert
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.