Skip to content

Commit af9496f

Browse files
authored
Don't register SIGTERM handler on Windows (#153)
1 parent d298aa2 commit af9496f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

functions_framework/lib/serve.dart

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,21 @@ Future<void> _serve(List<String> args, Set<FunctionTarget> targets) async {
9292
sigIntSub = null;
9393
await subCopy.cancel();
9494
sigIntSub = null;
95-
await sigTermSub.cancel();
96-
sigTermSub = null;
95+
if (sigTermSub != null) {
96+
await sigTermSub.cancel();
97+
sigTermSub = null;
98+
}
9799
completer.complete(true);
98100
}
99101
}
100102

101103
sigIntSub = ProcessSignal.sigint.watch().listen(signalHandler);
102-
sigTermSub = ProcessSignal.sigterm.watch().listen(signalHandler);
104+
105+
// SIGTERM is not supported on Windows. Attempting to register a SIGTERM
106+
// handler raises an exception.
107+
if (!Platform.isWindows) {
108+
sigTermSub = ProcessSignal.sigterm.watch().listen(signalHandler);
109+
}
103110

104111
await run(
105112
config.port, functionTarget.handler, completer.future, loggingMiddleware);

0 commit comments

Comments
 (0)