Skip to content

Commit

Permalink
chore: trap SIGINT, SIGTERM and SIGHUP for auto-closing
Browse files Browse the repository at this point in the history
  • Loading branch information
Mastercuber committed Aug 16, 2023
1 parent b40e7f4 commit e6d8e11
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/listen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export async function listen(
};

if (listhenOptions.showURL) {
showURL();
await showURL();
}

const _open = async () => {
Expand All @@ -243,7 +243,11 @@ export async function listen(
}

if (listhenOptions.autoClose) {
process.setMaxListeners(4);
process.on("exit", () => close());
process.on("SIGINT", () => process.exit(0)); // Ctrl + C
process.on("SIGTERM", () => process.exit(0)); // Terminate
process.on("SIGHUP", () => process.exit(0)); // Closed terminal
}

return <Listener>{
Expand Down

0 comments on commit e6d8e11

Please sign in to comment.