My android app launches a script using Runtime.exec(). The script in turn runs a command that starts a process. I want to capture the pid of that process, so I can keep track of its status and kill it later.
Here's an excerpt from my script:
$exec $options &
echo pid:$!:
I expect the pid to be echoed right away, but it's not. The command executes as expected, but the pid is not echoed until I manually kill the process that was started by the command. So it seems to be not respecting the request to run the command in the background. Am I doing it wrong, or does Android just not support this?
In case it matters, the command ($exec) that I'm running is a call to a binary executable, and $options expands to the arguments for that executable.