Giter Site home page Giter Site logo

process.dart's Introduction

Process

Moved

The source for the platform package has moved to the flutter/packages repository.


Build Status - Coverage Status -

A generic process invocation abstraction for Dart.

Like dart:io, package:process supplies a rich, Dart-idiomatic API for spawning OS processes.

Unlike dart:io, package:process:

  • Can be used to implement custom process invocation backends.
  • Comes with a record-replay implementation out-of-the-box, making it super easy to test code that spawns processes in a hermetic way.

process.dart's People

Contributors

a-siva avatar bernaferrari avatar goderbauer avatar gspencergoog avatar hixie avatar jamesderlin avatar jmagman avatar jonahwilliams avatar keertip avatar lambda-fairy avatar michaelrfairhurst avatar srawlins avatar stuartmorgan avatar tvolkert avatar zanderso avatar zolotyh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

process.dart's Issues

Where is the record-replay functionality

The readme talks about

Comes with a record-replay implementation out-of-the-box, making it super easy to test code that spawns processes in a hermetic way.

but I couldn't find any info about it except that it was removed.

See also:

[Bug] Can't run system commands in Windows.

I'm wondering If run designed to run executable?

example:

// Not working
processManager.run(['tasklist | findstr svchost.exe'], runInShell: true);
// error: '\"tasklist | findstr svchost.exe\"' is not recognized as an internal or external command,
// Neither(note)
processManager.run(['', 'tasklist | findstr svchost.exe'], runInShell: true);

So there is no possible to use these kind of commands, only for pure Process.

// Working
Process.run('tasklist | findstr svchost.exe', [], runInShell: true);
// Not working (note)
Process.run('', ['tasklist | findstr svchost.exe'], runInShell: true); 

Note: After viewing source code, I want to bypass this change, but It's not possible, Process.run with empty executable will give a double quote with empty space, see below:

'" "tasklist' is not recognized as an internal or external command,

The code affect this issue for Sanitizes the executable path on Windows.

  if (executable.contains(' ') && !executable.contains('"')) {
    // Use quoted strings to indicate where the file name ends and the arguments begin;
    // otherwise, the file name is ambiguous.
    return '"$executable"';
  }

Encoding parameters should be nullable

In the dart:io versions of the Process.run and runSync methods, the stderrEncoding and stdoutEncoding parameters are nullable. This library should be updated to match.

Due to backward compatibility constraints, this has to be done in two phases:

  1. Make the parameters nullable, but with a covariant keyword. This can be done in a patch release.
  2. Once all dependents are migrated, remove the covariant. This requires a major release.

When fs.currentDirectory throws, skip cwd relative search

In getExecutablePath, fs.currentDirectory is queried, but it can throw FileSystemException if e.g. getcwd() fails with EACCES, which can happen if the current process doesn't have read/list permissions from / up to the cwd.

Instead of propagating the exception, getExecutablePath should catch it, and just skip the cwd relative search.

flutter/flutter#57166

Dart 2 runtime failures in tests

Running tests in Dart 2 mode, see the following failure

00:02 +0 -2: RecordingProcessManager run [E]
type 'List' is not a subtype of type 'List' where
List is from dart:core
List is from dart:core
String is from dart:core

package:process/src/record_replay/common.dart 15:6 sanitize
package:process/src/record_replay/recording_process_manager.dart 147:37 RecordingProcessManager.run
===== asynchronous gap ===========================
dart:async _Completer.completeError
package:process/src/record_replay/recording_process_manager.dart RecordingProcessManager.run
===== asynchronous gap ===========================
dart:async _asyncThenWrapperHelper
package:process/src/record_replay/recording_process_manager.dart RecordingProcessManager.run
../../tmp/archives/third_party/dart/process/test/record_test.dart 65:25 main..
===== asynchronous gap ===========================
dart:async new Future.microtask
../../process/test/record_test.dart 63:17 main..

Child process not killed when program exit

I'm using Process in a Flutter project.
When the main application is closed, the child process started with run or either start is not terminated as well.

Does it an issue with the process itself?

 # pstree show process as child of fluter executable
❯ pstree -p 57234                 
-+= 00001 root /sbin/launchd
 \-+= 26078 pierozi /Applications/IntelliJ IDEA CE.app/Contents/MacOS/idea
   \-+- 56973 pierozi bash /Users/pierozi/Public/flutter/bin/flutter --no-color run --machine --track-widget-creat
     \-+- 56988 pierozi /Users/pierozi/Public/flutter/bin/cache/dart-sdk/bin/dart --packages=/Users/pierozi/Public
       \-+- 57228 pierozi /Users/pierozi/Project/github/plab/PeerVault-Client/build/macos/Build/Products/Debug/Peer
         \--- 57234 pierozi sleep 3600

# After flutter closed
❯ pstree -p 57234                       
-+= 00001 root /sbin/launchd
 \--- 57234 pierozi sleep 3600

ProcessManager.run signature is inconsistent with LocalProcessManager.run

ProcessManager has:

  Future<ProcessResult> run(
    List<dynamic> command, {
    String workingDirectory,
    Map<String, String> environment,
    bool includeParentEnvironment = true,
    bool runInShell = false,
    Encoding stdoutEncoding = systemEncoding,
    Encoding stderrEncoding = systemEncoding,
  });

LocalProcessManager has:

  @override
  Future<ProcessResult> run(
    covariant List<Object> command, {
    String? workingDirectory,
    Map<String, String>? environment,
    bool includeParentEnvironment = true,
    bool runInShell = false,
    Encoding stdoutEncoding = systemEncoding,
    Encoding stderrEncoding = systemEncoding,
  }) {

Is the difference in nullability for the workingDirectory and environment arguments intended? While legal, it's confusing, and I don't see any advantage to requiring non-null arguments in the base class.

Same for ProcessManager.start and LocalProcessManager.start.

getExecutablePath should only return executables

Right now, if I have the directory /tmp/bin in my PATH before /usr/bin, and it has a text file (mod 644, i.e. executable bit NOT set) in it called patch, then if I attempt to run 'patch' using Process.run or Process.start, then it will fail, because even though an executable patch exists in the PATH at /usr/bin/patch, it finds the one in /tmp/bin/patch instead and tries to execute it. It will succeed just fine if runInShell is set, since the shell skips non-executables.

getExecutablePath should, at least on Unix-like systems, only return files that have their executable bit set.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.