Capture IOException when file descriptor is closed (fixes #382)
Conflicts: src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingRunnable.java
This commit is contained in:
parent
767177e28d
commit
58d299a18e
|
@ -108,13 +108,15 @@ public class SyncthingRunnable implements Runnable {
|
||||||
process = pb.start();
|
process = pb.start();
|
||||||
mSyncthing.set(process);
|
mSyncthing.set(process);
|
||||||
|
|
||||||
log(process.getInputStream(), Log.INFO);
|
Thread lInfo = log(process.getInputStream(), Log.INFO);
|
||||||
log(process.getErrorStream(), Log.WARN);
|
Thread lWarn = log(process.getErrorStream(), Log.WARN);
|
||||||
|
|
||||||
niceSyncthing();
|
niceSyncthing();
|
||||||
|
|
||||||
ret = process.waitFor();
|
ret = process.waitFor();
|
||||||
mSyncthing.set(null);
|
mSyncthing.set(null);
|
||||||
|
lInfo.join();
|
||||||
|
lWarn.join();
|
||||||
|
|
||||||
if (ret == 3) {
|
if (ret == 3) {
|
||||||
Log.i(TAG, "Restarting syncthing");
|
Log.i(TAG, "Restarting syncthing");
|
||||||
|
@ -266,8 +268,8 @@ public class SyncthingRunnable implements Runnable {
|
||||||
*
|
*
|
||||||
* @param is The stream to log.
|
* @param is The stream to log.
|
||||||
*/
|
*/
|
||||||
private void log(final InputStream is, final int priority) {
|
private Thread log(final InputStream is, final int priority) {
|
||||||
new Thread(new Runnable() {
|
Thread t = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
@ -283,7 +285,9 @@ public class SyncthingRunnable implements Runnable {
|
||||||
Log.w(TAG, "Failed to read syncthing command line output", e);
|
Log.w(TAG, "Failed to read syncthing command line output", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).start();
|
});
|
||||||
|
t.start();
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue