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

Commit 265a1d28 authored by Elliott Hughes's avatar Elliott Hughes Committed by Android Git Automerger
Browse files

am 0888e52f: am afe5bbef: am a67914e4: Merge "Fix top(1) SIGPIPE behavior."

* commit '0888e52f':
  Fix top(1) SIGPIPE behavior.
parents b0cb721f 0888e52f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -97,6 +97,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");