claude-view 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +19 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -203,16 +203,32 @@ async function main() {
|
|
|
203
203
|
// Set STATIC_DIR so the server finds the frontend assets
|
|
204
204
|
const env = { ...process.env, STATIC_DIR: distDir };
|
|
205
205
|
|
|
206
|
-
// Run the server, forwarding signals and exit code
|
|
206
|
+
// Run the server, forwarding signals and exit code.
|
|
207
|
+
//
|
|
208
|
+
// Signal handling strategy:
|
|
209
|
+
// - SIGINT: Don't forward. Terminal sends SIGINT to the entire process group,
|
|
210
|
+
// so the child already receives it. Forwarding would double-deliver, causing
|
|
211
|
+
// the Rust server's graceful shutdown to see two SIGINTs from one Ctrl+C.
|
|
212
|
+
// - SIGTERM/SIGHUP: Forward. These may be sent to our PID only (e.g. from
|
|
213
|
+
// `kill` or a process manager), so the child wouldn't get them otherwise.
|
|
207
214
|
const child = spawn(binaryPath, process.argv.slice(2), { stdio: "inherit", env });
|
|
208
215
|
|
|
209
|
-
//
|
|
210
|
-
|
|
216
|
+
// Prevent Node from exiting on SIGINT before the child does.
|
|
217
|
+
const ignoreSigint = () => {};
|
|
218
|
+
process.on("SIGINT", ignoreSigint);
|
|
219
|
+
|
|
220
|
+
// Forward SIGTERM/SIGHUP — child may not receive these from process group.
|
|
221
|
+
for (const sig of ["SIGTERM", "SIGHUP"]) {
|
|
211
222
|
process.on(sig, () => child.kill(sig));
|
|
212
223
|
}
|
|
213
224
|
|
|
214
225
|
child.on("exit", (code, signal) => {
|
|
226
|
+
// Remove our SIGINT handler so the re-signal below uses default behavior.
|
|
227
|
+
process.removeListener("SIGINT", ignoreSigint);
|
|
228
|
+
|
|
215
229
|
if (signal) {
|
|
230
|
+
// Child was killed by signal — re-signal ourselves so the parent shell
|
|
231
|
+
// sees the correct exit status (128 + signal number).
|
|
216
232
|
process.kill(process.pid, signal);
|
|
217
233
|
} else {
|
|
218
234
|
process.exit(code ?? 1);
|