export function isPidAlive(pid: number): boolean { if (!isValidPid(pid)) { returnfalse;
} try {
process.kill(pid, 0);
} catch { returnfalse;
} if (isZombieProcess(pid)) { returnfalse;
} returntrue;
}
/** *Readtheprocessstarttime(field22"starttime")from/proc/<pid>/stat. *Returnsthevalueinclocktickssincesystemboot,ornullonnon-Linux *platformsoriftheprocfilecan'tberead. * *ThisisusedtodetectPIDrecycling:iftworeadingsforthesamePID *returndifferentstarttimes,thePIDhasbeenreusedbyadifferentprocess.
*/
export function getProcessStartTime(pid: number): number | null { if (process.platform !== "linux") { returnnull;
} if (!isValidPid(pid)) { returnnull;
} try { const stat = fsSync.readFileSync(`/proc/${pid}/stat`, "utf8"); const commEndIndex = stat.lastIndexOf(")"); if (commEndIndex < 0) { returnnull;
} // The comm field (field 2) is wrapped in parens and can contain spaces, // so split after the last ")" to get fields 3..N reliably. const afterComm = stat.slice(commEndIndex + 1).trimStart(); const fields = afterComm.split(/\s+/); // field 22 (starttime) = index 19 after the comm-split (field 3 is index 0). const starttime = Number(fields[19]); return Number.isInteger(starttime) && starttime >= 0 ? starttime : null;
} catch { returnnull;
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.