获取进程的退出状态码

2050次阅读  |  发布于5年以前

获取进程的退出状态码

Use Process.start() to start a process to run an executable. This function returns a new process that you can use to interact with the original process. You can use this returned process to obtain the exit code from executing the original process.

import 'dart:io';

main() async {
  var process = await Process.start('ls', ['-l']);
  // Get the exit code from the new process.
  var exitCode = await process.exitCode;
  print('exit code: $exitCode');
}

Copyright© 2013-2019

京ICP备2023019179号-2