0

I'm using the RootTools library, and I need to execute two commands. The first one runs a binary, the second sends SIGINT to it, to kill it.

RootTools (as far as I know) can only have one root shell open at a time, so commands can only be executed one by one. This is a problem, because I have no way to stop my binary after I've ran it.

How can I do any of the following things?

  • Execute two commands at once, so I can run my kill command when the binary is running
  • Send SIGINT to my native process some other way (e.g. with a RootTools function)

I need to use RootTools because it's the only way for me to read standard output from my program. If there's another way to do that, though, please comment.

superl2
  • 13
  • 1
  • 5

1 Answers1

0

Do you think you can concat the commands?

Let's say I want to launch a find command, but if it takes 5 seconds, I want it to stop:

find / & sleep 5 && kill $!

We can get a better suited one liner, too (i.e. ignore standard error, kill only if needed etc.).

You could also just store the PID and kill it later (be careful, if the daemon stopped to run, his PID can be reused by the OS):

  1. run the daemon in a root shell

    my-daemon >/dev/null & echo "PID: $!"
    
  2. parse the output in Java and store the PID (SharedPreferences?)

    var pid = outputLine.split(" ")[1]
    
  3. later on, stop the daemon with a root shell

    kill <pid>
    
MaxChinni
  • 1,206
  • 14
  • 21