* commit 'afe5bbefac2cd09a2a2e46777f6bba7afa9c2966': Fix top(1) SIGPIPE behavior.
This commit is contained in:
commit
0888e52fa8
2 changed files with 17 additions and 12 deletions
|
|
@ -95,6 +95,7 @@ LOCAL_SRC_FILES := \
|
||||||
LOCAL_C_INCLUDES := bionic/libc/bionic
|
LOCAL_C_INCLUDES := bionic/libc/bionic
|
||||||
|
|
||||||
LOCAL_CFLAGS += \
|
LOCAL_CFLAGS += \
|
||||||
|
-std=gnu99 \
|
||||||
-Wno-unused-parameter \
|
-Wno-unused-parameter \
|
||||||
-include bsd-compatibility.h \
|
-include bsd-compatibility.h \
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,16 +108,20 @@ static int proc_thr_cmp(const void *a, const void *b);
|
||||||
static int numcmp(long long a, long long b);
|
static int numcmp(long long a, long long b);
|
||||||
static void usage(char *cmd);
|
static void usage(char *cmd);
|
||||||
|
|
||||||
int top_main(int argc, char *argv[]) {
|
static void exit_top(int signal) {
|
||||||
int i;
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int top_main(int argc, char *argv[]) {
|
||||||
num_used_procs = num_free_procs = 0;
|
num_used_procs = num_free_procs = 0;
|
||||||
|
|
||||||
|
signal(SIGPIPE, exit_top);
|
||||||
|
|
||||||
max_procs = 0;
|
max_procs = 0;
|
||||||
delay = 3;
|
delay = 3;
|
||||||
iterations = -1;
|
iterations = -1;
|
||||||
proc_cmp = &proc_cpu_cmp;
|
proc_cmp = &proc_cpu_cmp;
|
||||||
for (i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (!strcmp(argv[i], "-m")) {
|
if (!strcmp(argv[i], "-m")) {
|
||||||
if (i + 1 >= argc) {
|
if (i + 1 >= argc) {
|
||||||
fprintf(stderr, "Option -m expects an argument.\n");
|
fprintf(stderr, "Option -m expects an argument.\n");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue