RootTools icon indicating copy to clipboard operation
RootTools copied to clipboard

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

Open hacker1024 opened this issue 7 years ago • 1 comments

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 avatar Jan 17 '18 09:01 hacker1024

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:

  • There is no way to "nicely" end a command with an unlimited timeout.
  • When the command is terminated with a kill command, commandOutput is only called for standard error.
  • commandOutput is only called after the program ends, so there's no way to get standard input while the program is running.

hacker1024 avatar Jan 17 '18 09:01 hacker1024