openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 698 B
JavaScript
import{i as e}from"./fs-safe-copy.worker-global-singleton-DIJgobpU.mjs";const t=e(Symbol.for(`openclaw.processExitCleanup`),()=>({}));function detachEmptyGroup(e){e.pending.size>0||(t.lastGroup===e&&(t.lastGroup=void 0),process.removeListener(`exit`,e.dispatch))}function registerProcessExitCleanup(e){let n={close:e},r=t.lastGroup;if(!r||process.listeners(`exit`).at(-1)!==r.dispatch){let e=/* @__PURE__ */ new Set([n]),i={pending:e,dispatch:()=>{let t=[...e];e.clear(),detachEmptyGroup(i);for(let e of t)try{e.close()}catch{}}};process.on(`exit`,i.dispatch),t.lastGroup=r=i}else r.pending.add(n);let i=r;return()=>{i.pending.delete(n),detachEmptyGroup(i)}}export{registerProcessExitCleanup as t};