google / process.dart Goto Github PK
View Code? Open in Web Editor NEWLicense: BSD 3-Clause "New" or "Revised" License
License: BSD 3-Clause "New" or "Revised" License
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
.
... so it can be used as a default parameter.
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
As of #3, it throws ArgumentError instead.
/cc @goderbauer
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..
For example, processManager.run(<String>['/path/to/a/binary', 'arg1', 'arg2']);
is going through this code path: https://github.com/google/process.dart/blob/master/lib/src/interface/local_process_manager.dart#L122 when I don't use runInShell
.
I don't want to use runInShell
though, I want it to just run the command to a process I have the abspath for.
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:
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:
covariant
keyword. This can be done in a patch release.covariant
. This requires a major release.The comment-based generics syntax will be removed from the Dart SDK tools (like DDC, analyzer) "soon." dart-lang/sdk#28796
Such syntax (like in _areListsEqual) needs to be updated, and the minimum Dart SDK in pubspec.yaml needs to be bumped to 1.21, when the real, non-comment-based syntax was introduced.
The published version of process doesn't support Dart 2:
https://pub.dartlang.org/packages/process#-analysis-tab-
However, looks like the pubspec in this repo does, so do we need to republish?
Also, there seems to be analysis issues: #26
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.
I'm implementing ProcessManager.start
and I don't understand what type I could receive in the first argument's list other than String, nor what to do with any other types.
It can be good to have a way to re-sync a process, like for example:
Process.reSync(PID)
and this will return a Process
object.
See flutter/flutter#13978 (comment).
That way it wouldn't matter if you accidentally pass a Linux-like executable path with \
as path separator on a Windows system. It would just work.
Not sure what the implications of this are. Is there ever a reason why you want to keep a \
in an executable path on Windows?
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.
The next flutter/engine -> flutter/flutter roll will receive a new 2.1.0-dev Dart SDK, which requires us to upgrade all 3rd party packages. Most of them have already newer versions published which are compatible with Dart 2, but the latest commits to this package:process
repository haven't been published yet.
@tvolkert @goderbauer Would you mind publishing a new version? (This is blocking flutter/flutter#20427)
This package should be in the google.dev publisher, but instead it's shown as belonging to an "unverified publisher".
The published version can currently not be traced to a source code version.
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"';
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.