Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a67914e4 authored by Elliott Hughes's avatar Elliott Hughes Committed by Gerrit Code Review
Browse files

Merge "Fix top(1) SIGPIPE behavior."

parents 958235bd 5922d3b5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ LOCAL_SRC_FILES := \
LOCAL_C_INCLUDES := bionic/libc/bionic

LOCAL_CFLAGS += \
    -std=gnu99 \
    -Wno-unused-parameter \
    -include bsd-compatibility.h \

+16 −12
Original line number Diff line number Diff line
@@ -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 void usage(char *cmd);

int top_main(int argc, char *argv[]) {
    int i;
static void exit_top(int signal) {
  exit(EXIT_FAILURE);
}

int top_main(int argc, char *argv[]) {
    num_used_procs = num_free_procs = 0;

    signal(SIGPIPE, exit_top);

    max_procs = 0;
    delay = 3;
    iterations = -1;
    proc_cmp = &proc_cpu_cmp;
    for (i = 1; i < argc; i++) {
    for (int i = 1; i < argc; i++) {
        if (!strcmp(argv[i], "-m")) {
            if (i + 1 >= argc) {
                fprintf(stderr, "Option -m expects an argument.\n");