psmisc: Use sysinfo() for uptime (fixes #4783)
This commit is contained in:
parent
7fe38d5121
commit
0fc2fdf849
@ -2,6 +2,7 @@ TERMUX_PKG_HOMEPAGE=https://gitlab.com/psmisc/psmisc
|
||||
TERMUX_PKG_DESCRIPTION="Some small useful utilities that use the proc filesystem"
|
||||
TERMUX_PKG_LICENSE="GPL-2.0"
|
||||
TERMUX_PKG_VERSION=23.3
|
||||
TERMUX_PKG_REVISION=1
|
||||
TERMUX_PKG_SRCURL=https://fossies.org/linux/misc/psmisc-$TERMUX_PKG_VERSION.tar.xz
|
||||
TERMUX_PKG_SHA256=41750e1a5abf7ed2647b094f58127c73dbce6876f77ba4e0a7e0995ae5c7279a
|
||||
TERMUX_PKG_DEPENDS="ncurses"
|
||||
|
@ -1,35 +0,0 @@
|
||||
Default to UTF-8 - may be overridden by command line flags.
|
||||
|
||||
diff -u -r ../psmisc-22.21/src/pstree.c ./src/pstree.c
|
||||
--- ../psmisc-22.21/src/pstree.c 2014-02-02 06:59:07.000000000 +0100
|
||||
+++ ./src/pstree.c 2014-06-30 18:35:12.064021186 +0200
|
||||
@@ -36,7 +36,9 @@
|
||||
#include <curses.h>
|
||||
#include <term.h>
|
||||
#include <termios.h>
|
||||
-#include <langinfo.h>
|
||||
+#ifndef __ANDROID__
|
||||
+# include <langinfo.h>
|
||||
+#endif
|
||||
#include <assert.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -1087,6 +1089,10 @@
|
||||
* command-line options, if given.
|
||||
*/
|
||||
|
||||
+#ifdef __ANDROID__
|
||||
+ /* Droids love unicode */
|
||||
+ sym = &sym_utf;
|
||||
+#else
|
||||
if (isatty(1) && !strcmp(nl_langinfo(CODESET), "UTF-8")) {
|
||||
/* Use UTF-8 symbols if the locale's character set is UTF-8. */
|
||||
sym = &sym_utf;
|
||||
@@ -1106,6 +1112,7 @@
|
||||
/* Otherwise, fall back to ASCII. */
|
||||
sym = &sym_ascii;
|
||||
}
|
||||
+#endif
|
||||
|
||||
#ifdef WITH_SELINUX
|
||||
while ((c =
|
39
packages/psmisc/src-killall.c.patch
Normal file
39
packages/psmisc/src-killall.c.patch
Normal file
@ -0,0 +1,39 @@
|
||||
diff -u -r ../psmisc-23.3/src/killall.c ./src/killall.c
|
||||
--- ../psmisc-23.3/src/killall.c 2019-09-19 23:21:56.148427745 +0000
|
||||
+++ ./src/killall.c 2020-01-12 00:31:59.382124339 +0000
|
||||
@@ -44,6 +44,10 @@
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
|
||||
+#ifdef __ANDROID__
|
||||
+#include <sys/sysinfo.h>
|
||||
+#endif
|
||||
+
|
||||
#ifdef WITH_SELINUX
|
||||
#include <selinux/selinux.h>
|
||||
#endif /*WITH_SELINUX*/
|
||||
@@ -132,6 +136,16 @@
|
||||
static double
|
||||
uptime()
|
||||
{
|
||||
+#ifdef __ANDROID__
|
||||
+ /* Android does not allow read access to /proc/uptime */
|
||||
+ struct sysinfo system_information;
|
||||
+ if (sysinfo(&system_information) == 0) {
|
||||
+ return (double) system_information.uptime;
|
||||
+ } else {
|
||||
+ fprintf(stderr, "pstree: error obtaining uptime from sysinfo\n");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+#else
|
||||
char * savelocale;
|
||||
char buf[2048];
|
||||
FILE* file;
|
||||
@@ -144,6 +158,7 @@
|
||||
fclose(file);
|
||||
setlocale(LC_NUMERIC,savelocale);
|
||||
return atof(buf);
|
||||
+#endif
|
||||
}
|
||||
|
||||
/* process age from jiffies to seconds via uptime */
|
69
packages/psmisc/src-pstree.c.patch
Normal file
69
packages/psmisc/src-pstree.c.patch
Normal file
@ -0,0 +1,69 @@
|
||||
diff -u -r ../psmisc-23.3/src/pstree.c ./src/pstree.c
|
||||
--- ../psmisc-23.3/src/pstree.c 2019-10-23 10:40:19.516725375 +0000
|
||||
+++ ./src/pstree.c 2020-01-12 00:27:42.797645090 +0000
|
||||
@@ -36,7 +36,9 @@
|
||||
#include <curses.h>
|
||||
#include <term.h>
|
||||
#include <termios.h>
|
||||
-#include <langinfo.h>
|
||||
+#ifndef __ANDROID__
|
||||
+# include <langinfo.h>
|
||||
+#endif
|
||||
#include <assert.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -47,6 +49,10 @@
|
||||
#include "i18n.h"
|
||||
#include "comm.h"
|
||||
|
||||
+#ifdef __ANDROID__
|
||||
+#include <sys/sysinfo.h>
|
||||
+#endif
|
||||
+
|
||||
#ifdef WITH_SELINUX
|
||||
#include <selinux/selinux.h>
|
||||
#else
|
||||
@@ -904,6 +910,16 @@
|
||||
static double
|
||||
uptime()
|
||||
{
|
||||
+#ifdef __ANDROID__
|
||||
+ /* Android does not allow read access to /proc/uptime */
|
||||
+ struct sysinfo system_information;
|
||||
+ if (sysinfo(&system_information) == 0) {
|
||||
+ return (double) system_information.uptime;
|
||||
+ } else {
|
||||
+ fprintf(stderr, "pstree: error obtaining uptime from sysinfo\n");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+#else
|
||||
char * savelocale;
|
||||
char buf[2048];
|
||||
FILE* file;
|
||||
@@ -916,6 +932,7 @@
|
||||
fclose(file);
|
||||
setlocale(LC_NUMERIC,savelocale);
|
||||
return atof(buf);
|
||||
+#endif
|
||||
}
|
||||
|
||||
/* process age from jiffies to seconds via uptime */
|
||||
@@ -1292,6 +1309,10 @@
|
||||
* command-line options, if given.
|
||||
*/
|
||||
|
||||
+#ifdef __ANDROID__
|
||||
+ /* Droids love unicode */
|
||||
+ sym = &sym_utf;
|
||||
+#else
|
||||
if (isatty(1) && !strcmp(nl_langinfo(CODESET), "UTF-8")) {
|
||||
/* Use UTF-8 symbols if the locale's character set is UTF-8. */
|
||||
sym = &sym_utf;
|
||||
@@ -1311,6 +1332,7 @@
|
||||
/* Otherwise, fall back to ASCII. */
|
||||
sym = &sym_ascii;
|
||||
}
|
||||
+#endif
|
||||
|
||||
#ifdef WITH_SELINUX
|
||||
while ((c =
|
Loading…
x
Reference in New Issue
Block a user