[Toybox] [PATCH] Fix ps infinite loop on Android.
enh
enh at google.com
Wed Oct 21 21:47:33 PDT 2015
I pasted this into a thread "smack support" on 2015-09-19, but it
looks like it got lost.
diff --git a/toys/pending/ps.c b/toys/pending/ps.c
index 29111d5..2bd7bcb 100644
--- a/toys/pending/ps.c
+++ b/toys/pending/ps.c
@@ -238,11 +238,12 @@ void ps_main(void)
TT.width--;
// find controlling tty, falling back to /dev/tty if none
- for (i = fd = 0; i < 4; i++) {
+ for (i = 0; i < 4; i++) {
struct stat st;
- if (i != 3 || -1 != (i = fd = open("/dev/tty", O_RDONLY))) {
- if (isatty(i) && !fstat(i, &st)) {
+ fd = i;
+ if (i != 3 || -1 != (fd = open("/dev/tty", O_RDONLY))) {
+ if (isatty(fd) && !fstat(fd, &st)) {
TT.tty = st.st_rdev;
break;
--
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.
1445489253.0
More information about the Toybox
mailing list