mirror of
https://github.com/wownero/cyberwow.git
synced 2026-10-20 08:48:43 +02:00
handle dead process
This commit is contained in:
@@ -30,7 +30,14 @@ import '../helper.dart';
|
||||
import '../../config.dart' as config;
|
||||
import '../../logging.dart';
|
||||
|
||||
Stream<String> runBinary (final String name, {final Stream<String> input}) async* {
|
||||
typedef IsExitingFunc = bool Function();
|
||||
|
||||
Stream<String> runBinary
|
||||
(
|
||||
final String name,
|
||||
final IsExitingFunc isExiting,
|
||||
{final Stream<String> input}
|
||||
) async* {
|
||||
final newPath = await getBinaryPath(name);
|
||||
|
||||
final appDocDir = await getApplicationDocumentsDirectory();
|
||||
@@ -78,7 +85,10 @@ Stream<String> runBinary (final String name, {final Stream<String> input}) async
|
||||
|
||||
if (config.isEmu) return;
|
||||
|
||||
// the app should never reach here
|
||||
if (!isExiting()) {
|
||||
log.warning('process is ded');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
log.info('Daemon exited gracefully.');
|
||||
// exit(0);
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ class _CyberWOW_PageState extends State<CyberWOW_Page> with WidgetsBindingObserv
|
||||
SyncingState _syncingState = await _loadingState.next(loading, '');
|
||||
|
||||
final syncing = process
|
||||
.runBinary(binName, input: inputStreamController.stream)
|
||||
.runBinary(binName, _isExiting, input: inputStreamController.stream)
|
||||
.asBroadcastStream();
|
||||
|
||||
HookedState _syncedNextState = await _syncingState.next(inputStreamController.sink, syncing);
|
||||
@@ -195,7 +195,7 @@ class _CyberWOW_PageState extends State<CyberWOW_Page> with WidgetsBindingObserv
|
||||
_exiting = true;
|
||||
inputStreamController.sink.add('exit');
|
||||
|
||||
await Future.delayed(const Duration(seconds: 10), () => null);
|
||||
await Future.delayed(const Duration(seconds: 5), () => null);
|
||||
|
||||
// the process controller should call exit(0) for us
|
||||
log.warning('Daemon took too long to shut down!');
|
||||
|
||||
Reference in New Issue
Block a user