Files
sdk/pkg/dart_data_home/test/common/test_script.dart
Slava Egorov 907c4838fd [dart_data_home] Add PID files helpers
createPidFile(dir, content) can be used to create the pid file for 
the current process with the given content in the dir.

listPidFiles(dir) can be used to list pid files in the given directory.

Both functions will purge stale pid files from the given directory.
The implementation operates under the assumption that there is only
a small number of processes using pid files running at any given
time so there will ever be only a very small number of pid files
in the directory.

TEST=pid_files_test

Change-Id: Id83a7f6138511f755ab47347c17b44d66a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487000
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Jaime Wren <jwren@google.com>
2026-03-12 07:11:47 -07:00

25 lines
685 B
Dart

// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'dart:io';
import 'package:dart_data_home/src/pid_files.dart';
Future<void> main(List<String> args) async {
if (args.length < 2) {
print('Usage: test_script.dart <package_name> <pid_file_content>');
exit(1);
}
if (!createPidFile(args[0], args[1])) {
throw StateError('Failed to create pid file');
}
print('OK:$pid');
while (true) {
await Future<void>.delayed(const Duration(seconds: 1));
print('.');
}
}