Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A process with mode detachedWithStdio has a null getter for exitCode. #35874

Closed
grouma opened this issue Feb 6, 2019 · 4 comments
Closed

A process with mode detachedWithStdio has a null getter for exitCode. #35874

grouma opened this issue Feb 6, 2019 · 4 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends.

Comments

@grouma
Copy link
Member

grouma commented Feb 6, 2019

This applications throws when it shouldn't:

import 'dart:io';

void main() async {
  var process =
      await Process.start('ls', [], mode: ProcessStartMode.detachedWithStdio);
  process.exitCode.then((_) {});
}
@vsmenon vsmenon added the area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. label Feb 7, 2019
@bkonyi
Copy link
Contributor

bkonyi commented Feb 28, 2019

Started looking into this and it appears that this is working as intended based on the documentation.

In particular:

If mode is ProcessStartMode.detachedWithStdio a detached process will be created where the stdin, stdout and stderr are connected. The creator can communicate with the child through these. The detached process will keep running even if these communication channels are closed. The process' exit code will not become available when it terminated.

ProcessStartMode.detached behaves similarly. Exit codes are only available when using ProcessStartMode.normal.

@bkonyi bkonyi closed this as completed Feb 28, 2019
@grouma
Copy link
Member Author

grouma commented Mar 4, 2019

Interesting that this behavior is documented. Is this due to a technical limitation? I can't fathom why this would be the preferred behavior.

@iinozemtsev
Copy link
Member

Just learned this in a hard (~2 hours searing for an error in my code then reading through process_patch.dart) way.

While this is nice to have a doc in Process.start, it would be also helpful to mention this fact in exitCode getter

@vanlooverenkoen
Copy link

Is there any way to know if the command failed or succeeded?

copybara-service bot pushed a commit that referenced this issue Nov 7, 2023
In response to #35874

The class level doc mentions the restriction that `exitCode` is
unavailable for detached processes. Repeat this in the doc for that
member since it is the API where it is the most relevant.

Change-Id: I14ca7bd32614b1d1c1ae4a7d96d87428215d3dd7
CoreLibraryReviewExempt: Doc change.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334360
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Auto-Submit: Nate Bosch <nbosch@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

5 participants