Skip to content

ProcessSignal.sigint.watch() does not work correctly with dart.exe #61399

@bkonyi

Description

@bkonyi

This was discovered when we noticed that the Flutter tool was leaking processes on Windows and realized that the shutdown hooks were not executing correctly when the process was sent SIGINT (see flutter/flutter#173616).

To reproduce, run the following program using dart.exe and dartvm.exe:

// signal.dart
import 'dart:io';

main() async {
  ProcessSignal.sigint.watch().listen((_) {
     print('SIGINT RECEIVED');
     exit(0);
  });
  
  while(true) {
    await Future.delayed(const Duration(seconds: 1));
    print('Waiting...');
  }
}

When run from source using dartvm.exe, sending SIGINT results in the signal handler being invoked:

PS C:\dart_sdk\sdk> C:\Users\tenpi\flutter\bin\cache\dart-sdk\bin\dartvm.exe signal.dart
Waiting...
Waiting...
SIGINT RECEIVED
PS C:\dart_sdk\sdk>

However, when running from source using dart.exe, sending SIGINT results in the process being killed, but the signal handler isn't invoked (at least, it fails to run most of the time):

PS C:\dart_sdk\sdk> C:\Users\tenpi\flutter\bin\cache\dart-sdk\bin\dart.exe signal.dart  
Waiting...
Waiting...
PS C:\dart_sdk\sdk> 

This is almost certainly a regression from the recent migration of dart.exe to exec(...) dartvm.exe when running Dart code from source.

Metadata

Metadata

Assignees

Labels

P1A high priority bug; for example, a single project is unusable or has many test failuresarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-ioos-windowstriagedIssue has been triaged by sub team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions