top: fix a fix for the 'bye_bye' function (merge #127)

In the merge request shown below, 1 too many bytes are
written to stdout thus including the terminating null.
As the cure, this commit just reduces the length by 1.

[ along the way, we will remove some unneeded braces ]
[ plus add some additional comments with attribution ]

Reference(s):
https://gitlab.com/procps-ng/procps/-/merge_requests/127
. original merged change
commit 0bf15c004d

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2021-06-21 00:00:00 -05:00 committed by Craig Small
parent dc8137f85b
commit 37f1060299

View File

@ -569,13 +569,21 @@ static void bye_bye (const char *str) {
#endif // end: OFF_HST_HASH
numa_uninit();
/* we'll only have a 'str' if called by error_exit() |
or that xalloc_our_handler() function. if we were |
called from a sig_endpgm(), that parm is NULL ... | */
if (str) {
fputs(str, stderr);
exit(EXIT_FAILURE);
}
if (Batch) {
write(fileno(stdout), "\n", sizeof("\n"));
}
/* this could happen when called from several places |
including that sig_endpgm(). thus we must use an |
async-signal-safe write function just in case ... |
(thanks: Shaohua Zhan shaohua.zhan@windriver.com) | */
if (Batch)
write(fileno(stdout), "\n", sizeof("\n") - 1);
exit(EXIT_SUCCESS);
} // end: bye_bye