openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.49 kB
JavaScript
import{t as e}from"./fs-safe-copy.worker-errno-CsW5NI8i.mjs";import{a as t,o as n}from"./fs-safe-copy.worker-service-child-group-ownership-D9CheQE8.mjs";import"./fs-safe-copy.worker-command-process-identity-CeGBvJe9.mjs";function shouldDetachChildForProcessTree(){return process.platform!==`win32`}function isDeniedProcessGroupProbe(t,n=0){if(process.platform!==`linux`||!e(t,`EPERM`))return!1;try{return process.kill(-4194305,n),!1}catch(t){return e(t,`EPERM`)}}function probeProcessGroup(t){try{return process.kill(-t,0),`alive`}catch(t){return e(t,`ESRCH`)?`gone`:isDeniedProcessGroupProbe(t)?`denied`:`alive`}}function isProcessGroupGoneByKernel(e){return probeProcessGroup(e)===`gone`}function isProcessGroupGone(e){let n=probeProcessGroup(e);return n===`gone`||n===`denied`&&t(e)}async function isProcessGroupGoneAsync(e){let t=probeProcessGroup(e);return t===`gone`||t===`denied`&&await n(e)}async function isChildProcessTreeAliveAsync(e){return typeof e.pid!=`number`||e.pid<=0?!1:shouldDetachChildForProcessTree()?!await isProcessGroupGoneAsync(e.pid):isChildProcessTreeAlive(e)}function isChildProcessTreeAlive(t){if(typeof t.pid!=`number`||t.pid<=0)return!1;if(shouldDetachChildForProcessTree())return!isProcessGroupGone(t.pid);try{return process.kill(t.pid,0),!0}catch(t){return!e(t,`ESRCH`)}}export{isProcessGroupGoneAsync as a,isProcessGroupGone as i,isChildProcessTreeAliveAsync as n,isProcessGroupGoneByKernel as o,isDeniedProcessGroupProbe as r,isChildProcessTreeAlive as t};