@meyverick/omnicode 0.1.1 → 0.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meyverick/omnicode",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Cross-platform command-line entrypoint for OpenCode through OmniRoute",
5
5
  "type": "module",
6
6
  "bin": {
@@ -123,7 +123,7 @@ async function stopOmnirouteIfIdle(pidFile) {
123
123
  }
124
124
  for (let i = 0; i < 10; i++) {
125
125
  if (!isPidAlive(pid)) break;
126
- try { process.kill(pid, 0); } catch { break; }
126
+ await sleep(100);
127
127
  }
128
128
  }
129
129
  try { unlinkSync(pidFile); } catch {}
@@ -142,7 +142,16 @@ export async function runRuntime(mode) {
142
142
  }
143
143
 
144
144
  const cleanup = async () => { await stopOmnirouteIfIdle(pidFile); };
145
- process.on("exit", () => {});
145
+ process.on("exit", () => {
146
+ try {
147
+ if (!existsSync(pidFile)) return;
148
+ const pid = parseInt(readFileSync(pidFile, "utf8").trim(), 10);
149
+ if (pid && isPidAlive(pid)) {
150
+ process.kill(-pid, "SIGTERM");
151
+ }
152
+ unlinkSync(pidFile);
153
+ } catch {}
154
+ });
146
155
  process.on("SIGINT", async () => { await cleanup(); process.exit(0); });
147
156
  process.on("SIGTERM", async () => { await cleanup(); process.exit(0); });
148
157