Stericson / RootTools

RootTools Library
1.6k stars 484 forks source link

When a command is terminated with something like the linux "kill" command, commandOutput is only called for lines from standard error. #76

Open hacker1024 opened 6 years ago

hacker1024 commented 6 years ago

I've overrided commandOutput like this:

override fun commandOutput(id: Int, line: String?) {
    Log.d("command-output", line)
    super.commandOutput(id, line)
}

Command.terminate() and Command.finish() don't kill my command (#77), so I have to kill it with another root command.

My Command object has a timeout of zero (maybe related to this?) No output is logged until I kill the native command, and then only the last line is logged.

Everything works fine with a program that ends on its own, like ls.

Note: If I deliberately run my native binary in a non-root shell (so it prints an error and exits) all output is printed correctly.

EDIT: I forgot to say - the last line in my native program (which is the only line printed) is the only line also printed to standard error.

hacker1024 commented 6 years ago

After some testing I've realized what's actually happening; it isn't only the last line being printed, it's standard error. So, the real issues are: