0
votes

First sorry for my bad English.

I have developed an app in Android Studio. It call tcpdump (Process process = Runtime.getRuntime().exec("su -c tcpdump -s 0 -v -w /sdcard/capture.pcap");). Initially it works correctly. However, tcpdump process is killed abruptly. Would anyone tell me why?

Thank you

1

1 Answers

0
votes

It might tell you why on standard error:

final Process p = Runtime.getRuntime().exec(tcpdumpCommand);
final BufferedReader reader = new BufferedReader(
    new InputStreamReader(p.getErrorStream()));
(new Thread() {
  public void run() {
    while ((line = reader.readLine()) != null) {
      Log.d("tcpdump", "stderr: " + line);
    }
    Log.d("tcpdump", "end of stderr");
  }
}).start();

...and then look in logcat. Or try the same with getOutputStream() (for stdout) instead of getErrorStream().

Also if tcpdump was successfully capturing traffic and then abruptly stopped, one possible reason is you've filled the SD card.