tekartik / process_run.dart

Process run helper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to terminate shell process which was not awaited.

riseryan89 opened this issue · comments

commented

I have tried ssh command and ssh process is still running after quit.

Any solutions?

[✓] Flutter (Channel dev, 2.2.0-10.1.pre, on Mac OS X 10.15.7 19H114 darwin-x64)
[✗] Android toolchain - develop for Android devices
✗ ANDROID_HOME = /usr/local/share/android-sdk
but Android SDK not found at this location.
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.0)
[✓] IntelliJ IDEA Community Edition (version 2020.3.2)
[✓] Connected device (2 available)

Not sure what is specific about ssh but if indeed the process is spawned without context, there is not much we can do.

You can however try the Shell.kill method to 'kill' the running process in the Shell. See an example here:

import 'package:process_run/shell.dart';

void main(List<String> arguments) async {
  var sw = Stopwatch()..start();
  var shell = Shell();
  // ignore: unawaited_futures
  shell.run('sleep 5');

  await Future.delayed(Duration(seconds: 2));

  // command should last for 5 seconds but we kill it after 2!
  shell.kill();
}

How to send crtl +c to shell? i'm runnig node but not kill shell

image

Tried "shell.kill(ProcessSignal.sigint)" but not working