1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 11:21:29 +00:00

Handle exit code 137 caused by SIGKILL.

Also don't restart Syncthing twice (via loop and via intent).
This commit is contained in:
Felix Ableitner 2016-04-04 22:43:50 +02:00
parent 88abd80c66
commit 7f090e3653

View file

@ -108,8 +108,6 @@ public class SyncthingRunnable implements Runnable {
try {
if (wakeLock != null)
wakeLock.acquire();
// Loop to handle Syncthing restarts (these always have an error code of 3).
do {
ProcessBuilder pb = (useRoot())
? new ProcessBuilder("su", "-c", TextUtils.join(" ", mCommand))
: new ProcessBuilder(mCommand);
@ -136,18 +134,28 @@ public class SyncthingRunnable implements Runnable {
lInfo.join();
lWarn.join();
switch (ret) {
case 0:
case 2:
case 4:
// Valid exit codes, ignored.
break;
case 3:
// Restart if that was requested via Rest API call.
if (ret == 3) {
Log.i(TAG, "Restarting syncthing");
mContext.startService(new Intent(mContext, SyncthingService.class)
.setAction(SyncthingService.ACTION_RESTART));
}
break;
case 137:
// Ignore SIGKILL that we use to stop Syncthing.
break;
case 1:
// fallthrough
default:
// Force crash if Syncthing exits with an error.
else if (ret == 1 || ret > 4) {
throw new RuntimeException("Syncthing binary crashed with error code " +
Integer.toString(ret) + ", output:\n" + mErrorLog);
}
} while (ret == 3);
} catch (IOException | InterruptedException e) {
Log.e(TAG, "Failed to execute syncthing binary or read output", e);
} finally {