Files
core/system/base/procps/files/procps-3.2.7-ps-stime.patch
T
2015-02-24 11:18:35 +02:00

72 lines
2.2 KiB
Diff

--- procps-3.2.7/ps/output.c.jitter 2007-04-26 13:15:47.000000000 +0200
+++ procps-3.2.7/ps/output.c 2007-04-26 13:31:24.000000000 +0200
@@ -77,7 +77,6 @@
static int wide_signals; /* true if we have room */
static unsigned long seconds_since_1970;
-static unsigned long time_of_boot;
static unsigned long page_shift;
@@ -1952,7 +1951,6 @@
// available space: page_size*outbuf_pages-SPACE_AMOUNT
seconds_since_1970 = time(NULL);
- time_of_boot = seconds_since_1970 - seconds_since_boot;
meminfo();
--- procps-3.2.7/ps/common.h.jitter 2005-01-27 04:43:22.000000000 +0100
+++ procps-3.2.7/ps/common.h 2007-04-26 12:44:01.000000000 +0200
@@ -302,6 +302,7 @@
extern int screen_cols;
extern int screen_rows;
extern unsigned long seconds_since_boot;
+extern unsigned long time_of_boot;
extern selection_node *selection_list;
extern unsigned simple_select;
extern sort_node *sort_list;
--- procps-3.2.7/ps/global.c.jitter 2005-10-30 01:43:34.000000000 +0200
+++ procps-3.2.7/ps/global.c 2007-04-26 13:26:38.000000000 +0200
@@ -70,6 +70,7 @@
int screen_cols = -1;
int screen_rows = -1;
unsigned long seconds_since_boot = -1;
+unsigned long time_of_boot = -1;
selection_node *selection_list = (selection_node *)0xdeadbeef;
unsigned simple_select = 0xffffffff;
sort_node *sort_list = (sort_node *)0xdeadbeef; /* ready-to-use sort list */
@@ -361,7 +362,23 @@
look_up_our_self(&p);
set_screen_size();
set_personality();
-
+ int fd;
+ char *buf[BUFFSIZE];
+ const char *b;
+
+ /* get boot time from /proc/stat */
+ fd = open("/proc/stat", O_RDONLY, 0);
+ if (fd != -1) {
+ buf[BUFFSIZE-1] = 0;
+ read(fd, buf, BUFFSIZE-1);
+ b = strstr(buf, "btime ");
+ if (b) {
+ sscanf(b, "btime %lu", &time_of_boot);
+ seconds_since_boot = time(0) - time_of_boot;
+ }
+ close(fd);
+ }
+
all_processes = 0;
bsd_c_option = 0;
bsd_e_option = 0;
@@ -380,7 +397,6 @@
negate_selection = 0;
page_size = getpagesize();
running_only = 0;
- seconds_since_boot = uptime(0,0);
selection_list = NULL;
simple_select = 0;
sort_list = NULL;