Comments (7)
One does not simply write to /dev/stderr
Did you modify your example? The email I got from GitHub contained: ls -l >/dev/stderr /
, instead of ls -l / >/dev/stderr
, which obviously has a / in the wrong place.
Other than that, you should write to >&2 instead of >/dev/stderr, like so:
suResult = Shell.run("su", new String[] {
"id",
"ls -l / >&2"
}, null, true);
Works fine here ... writing to /dev/stderr will throw an error. &2 stands for file descriptor 2. 0 is STDIN, 1 is STDOUT, 2 is STDERR.
from libsuperuser.
Yes I had a typo in the example (been a bit too early, and I didn't get enough coffee yet). About wrong use of stderr, I didn't see any errors... but it should still write something to STDERR, doesn't it? But like I stated above I couldn't even get the debugger into the run() method.
Originally I hit on the issue in another project (before modifying the sample project) and there I'm executing the "pm" command - which calls System.err.println("....") - and I still get no result in the STDERR gobbler. On the contrary when using the Interactive shell instead then the result appears just fine in the STDERR listener.
I'll do some more tests tomorrow morning. If you know of some more things I could try then please let me know.
from libsuperuser.
No, it should not write something to STDERR. Again, you do not write to STDERR by writing to /dev/stderr, you write to STDERR by writing to fd 2, in other words, >&2
. On some systems and running in some shells, /dev/stderr is symlinked to /proc/self/fd/2, but this is not guaranteed to be the case, and indeed it is often not the case. Strike /dev/stderr from your mind and never use it again, it is not correct, using &2
is.
The reason you're not seeing an error is because if you run as su, and /dev/stderr doesn't exist, you're actually writing the output to a new file called /dev/stderr (and thus no output in Java)... running as normal sh, you'd get a permission denied error (because you cannot create files in /dev).
While it's certainly interesting that you don't get the result from your pm
command and we should figure out why, I'd need a repro case that actually demonstrates the problem :)
from libsuperuser.
Sorry for the bad example. Yes, I had tested it in Terminal Emulator few minutes ago I already figured out writing to stderr didn't drop any output on my phone when run as su. I'll tell you more tomorrow when I'm back at my #androiddev machine ;)
from libsuperuser.
I'm afraid the issue is hard to reproduce. In my tests I did run commands like that:
suResult = Shell.run("su", new String[] {
"id",
"pm disable com.koushikdutta.superuser",
"pm disable com.koushikdutta.superuser",
"pm disable com.koushikdutta.superuser",
"yikes", "yikes", "yikes"
}, null, true);
On the first two attempts I didn't see any result at all, afterwards it did work most of the time. I've been testing different variations of the above example for like 30 minutes and seen it with no results like only 5-6 times.
from libsuperuser.
Has there been any changes in this behavior? Have you tried with newer commits? Trying to figure if this is still an issue or not.
from libsuperuser.
Sorry I still didn't have any time to look into the issues again. As it seems noone else did run into it I guess it can be closed for now. I'll be using libSuperuser in all my projects sooner or later and will re-open the issue with more details if the problem appears again.
from libsuperuser.
Related Issues (20)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libsuperuser.