1 Ignore Permission denied in several places.
3 On some Androids many of proc files can't actually be opened. So ignore
4 when opening fails and go on.
6 diff '--exclude=config.log' -ur src-orig/proc/sysinfo.c src/proc/sysinfo.c
7 --- src-orig/proc/sysinfo.c 2017-08-26 23:22:50.704748922 +0200
8 +++ src/proc/sysinfo.c 2017-08-27 00:08:52.482479053 +0200
13 + if (uptime_fd == -1 && (uptime_fd = open(UPTIME_FILE, O_RDONLY)) == -1) {
17 FILE_TO_BUF(UPTIME_FILE,uptime_fd);
19 savelocale = strdup(setlocale(LC_NUMERIC, NULL));
21 /* /proc/stat can get very large on multi-CPU systems so we
22 can't use FILE_TO_BUF */
23 if (!(f = fopen(STAT_FILE, "r"))) {
25 fputs(BAD_OPEN_MESSAGE, stderr);
32 + if (loadavg_fd == -1 && (loadavg_fd = open(LOADAVG_FILE, O_RDONLY)) == -1) {
36 FILE_TO_BUF(LOADAVG_FILE,loadavg_fd);
38 savelocale = strdup(setlocale(LC_NUMERIC, NULL));
39 diff '--exclude=config.log' -ur src-orig/top/top.c src/top/top.c
40 --- src-orig/top/top.c 2017-08-26 23:22:50.708748956 +0200
41 +++ src/top/top.c 2017-08-27 00:13:34.416643298 +0200
43 (sorry Linux, but you'll have to close it for us) */
45 if (!(fp = fopen("/proc/stat", "r")))
46 - error_exit(fmtmk(N_fmt(FAIL_statopn_fmt), strerror(errno)));
48 /* note: we allocate one more CPU_t via totSLOT than 'cpus' so that a
49 slot can hold tics representing the /proc/stat cpu summary */
50 cpus = alloc_c(totSLOT * sizeof(CPU_t));
52 tmptty.c_cc[VERASE] = *key_backspace;
54 if (-1 == tcsetattr(STDIN_FILENO, TCSAFLUSH, &tmptty))
55 - error_exit(fmtmk(N_fmt(FAIL_tty_set_fmt), strerror(errno)));
57 tcgetattr(STDIN_FILENO, &Tty_tweaked);
59 // lastly, a nearly raw mode for unsolicited single keystrokes
61 tmptty.c_cc[VMIN] = 1;
62 tmptty.c_cc[VTIME] = 0;
63 if (-1 == tcsetattr(STDIN_FILENO, TCSAFLUSH, &tmptty))
64 - error_exit(fmtmk(N_fmt(FAIL_tty_set_fmt), strerror(errno)));
66 tcgetattr(STDIN_FILENO, &Tty_raw);
71 if (!Numa_node_tot) goto numa_nope;
73 - if (CHKw(w, View_CPUNOD)) {
74 + if (smpcpu && CHKw(w, View_CPUNOD)) {
75 if (Numa_node_sel < 0) {
76 // display the 1st /proc/stat line, then the nodes (if room)
77 summary_hlp(&smpcpu[smp_num_cpus], N_txt(WORD_allcpus_txt));
78 @@ -5191,12 +5191,12 @@
82 - if (CHKw(w, View_CPUSUM)) {
83 + if (smpcpu && CHKw(w, View_CPUSUM)) {
84 // display just the 1st /proc/stat line
85 summary_hlp(&smpcpu[Cpu_faux_tot], N_txt(WORD_allcpus_txt));
89 + } else if (smpcpu) {
90 // display each cpu's states separately, screen height permitting...
91 for (i = 0; i < Cpu_faux_tot; i++) {
92 snprintf(tmp, sizeof(tmp), N_fmt(WORD_eachcpu_fmt), smpcpu[i].id);