MCPcopy
hub / github.com/microsoft/playwright / sigintHandler

Function sigintHandler

packages/utils/processLauncher.ts:75–100  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73
74let sigintHandlerCalled = false;
75function sigintHandler() {
76 const exitWithCode130 = () => {
77 // Give tests a chance to see that launched process did exit and dispatch any async calls.
78 if (isUnderTest()) {
79 // eslint-disable-next-line no-restricted-properties
80 setTimeout(() => process.exit(130), 1000);
81 } else {
82 // eslint-disable-next-line no-restricted-properties
83 process.exit(130);
84 }
85 };
86
87 if (sigintHandlerCalled) {
88 // Resort to default handler from this point on, just in case we hang/stall.
89 process.off('SIGINT', sigintHandler);
90
91 // Upon second Ctrl+C, immediately kill browsers and exit.
92 // This prevents hanging in the case where closing the browser takes a lot of time or is buggy.
93 for (const kill of killSet)
94 kill();
95 exitWithCode130();
96 } else {
97 sigintHandlerCalled = true;
98 gracefullyCloseAll().then(() => exitWithCode130());
99 }
100}
101
102function sigtermHandler() {
103 gracefullyCloseAll();

Callers

nothing calls this directly

Calls 4

exitWithCode130Function · 0.85
gracefullyCloseAllFunction · 0.85
thenMethod · 0.80
offMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…