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 ported cchange commit 6b8980a3b6279058d727377e914cfb6439d6f178 Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
24e4e1f5c3
commit
27e60e86e9
12
top/top.c
12
top/top.c
@ -415,13 +415,19 @@ static void bye_bye (const char *str) {
|
|||||||
procps_pids_unref(&Pids_ctx);
|
procps_pids_unref(&Pids_ctx);
|
||||||
procps_stat_unref(&Stat_ctx);
|
procps_stat_unref(&Stat_ctx);
|
||||||
|
|
||||||
|
/* we'll only have a 'str' if called by error_exit() |
|
||||||
|
not ever from the sig_endpgm() signal handler ... | */
|
||||||
if (str) {
|
if (str) {
|
||||||
fputs(str, stderr);
|
fputs(str, stderr);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (Batch) {
|
/* this could happen when called from several places |
|
||||||
write(fileno(stdout), "\n", sizeof("\n"));
|
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);
|
exit(EXIT_SUCCESS);
|
||||||
} // end: bye_bye
|
} // end: bye_bye
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user