export interface ProcessIdentity { pid: number; /** وقت بدء العملية بصيغة ISO. هو المميّز الحقيقي: رقم الـ PID وحده لا يميّز. */ startedAt: string; commandLine: string; } /** * يقرأ هوية عملية حيّة. يُرجع undefined إذا لم تعد موجودة. * على غير ويندوز لا نملك مصدرًا موحّدًا للهوية، فنكتفي بفحص الوجود ونعيد هوية فارغة الحقول. */ export declare function readProcessIdentity(pid: number): Promise; /** * هل العملية الحيّة هي نفسها التي سجّلناها؟ * وقت البدء هو الفيصل. غيابه (غير ويندوز) يجعلنا نكتفي بالوجود، وهو أضعف لكنه أفضل المتاح. */ export declare function identityMatches(recorded: Pick, live: ProcessIdentity | undefined): boolean; /** * AR: **هل الرقم موجودٌ الآن؟** ‎signal 0‎ يسأل بلا أن يرسل شيئًا، و‎EPERM‎ يعني «موجودة بحسابٍ آخر» * (خدمات الجهاز يطلقها ‎SYSTEM‎). سؤالٌ فوريّ بلا عمليّةٍ فرعيّة، بخلاف استعلام ‎CIM‎. * EN: **Does the pid exist right now?** `signal 0` asks without sending anything, and `EPERM` means * "exists, owned by another account" (the appliance's services are launched by SYSTEM). An instant * question with no child process, unlike the `CIM` query. */ export declare function pidExists(pid: number): boolean; export interface AliveOptions { /** * التحقّق من الهويّة (حمايةً من رقمٍ أُعيد استعماله). ‎false‎ حين تكون العمليّة قد أُطلقت قبل ثوانٍ — * لا يُعاد استعمال رقمها في تلك الثواني — فيُوفَّر استعلامٌ ثقيل في كل جولة انتظار. */ confirmIdentity?: boolean; /** تُحقَن في الاختبار. */ exists?: (pid: number) => boolean; identity?: (pid: number) => Promise; } /** * AR: هل الـ PID المسجَّل ما زال هو عمليتنا؟ * * **«لم نستطع أن نعرف» ليست «ماتت».** كان الجواب يُبنى على استعلام ‎CIM‎ وحده، واستعلامٌ يتأخّر عن * مهلته — أو يُرفض — يعيد ‎undefined‎، فيُقرأ موتًا. وثمن ذلك كان نظامًا سليمًا يُهدَم: خدمةٌ تُقلع * فعلًا تُعلَن «خرجت قبل أن تجهز» فيتراجع ‎start‎ عن إقلاعٍ صحيح، و‎stop‎ لا يجد ما يوقفه فتبقى * العمليّة حيّة بلا سجلّ، و‎status‎ يقول «متوقّفة» عن خدمةٍ تعمل. وهو ما يقع بالضبط حين يكون الجهاز * مشغولًا — أي أثناء إقلاعٍ بارد بعد تحديث. * * فالترتيب: **وجودُ الرقم أوّلًا** (سؤالٌ فوريّ لا يكذب)، ثم الهويّة تأكيدًا. وإن وُجد الرقم وتعذّرت * قراءة الهويّة، فالعمليّة **حيّة**: خطأُ «حيّة وهي ميتة» انتظارٌ ثوانٍ، وخطأُ العكس يقتل نظامًا يعمل. * EN: Is the recorded pid still our process? * * **"We could not tell" is not "it died."** The answer used to rest on the `CIM` query alone, and a * query that overruns its timeout — or is refused — returns `undefined`, which was read as death. * The price was a sound system torn down: a service that is genuinely starting is declared "exited * before it became ready" so `start` rolls back a correct boot, `stop` finds nothing to stop and * leaves the process running with no record, and `status` calls a running service stopped. Which is * exactly what happens when the machine is busy — that is, during a cold boot after an update. * * So the order is: **the pid's existence first** (an instant question that does not lie), then * identity as confirmation. If the pid exists and identity cannot be read, the process is **alive**: * being wrong that way costs seconds of waiting, and being wrong the other way kills a working system. */ export declare function isRecordedProcessAlive(record: Pick, options?: AliveOptions): Promise; /** * AR: **وقت بدء العملية من سطر ‎/proc//stat‎، بوحدات الساعة.** * * دالّةٌ خالصة تأخذ نصًّا، **لأن ما فيها يحتاج اختبارًا ولا يمكن اختباره بقراءة ‎/proc‎**: * الحالات التي تكسرها لا تُصنَع بالطلب على آلة. * * **والاسم بين قوسين قد يحوي مسافاتٍ وأقواسًا.** ‎proc(5)‎ يضع الاسم في الحقل الثاني بين * ‎(‎ و‎)‎ بلا هروب — فعمليةٌ اسمها ‎(my app)‎ أو ‎a b c‎ تُزيح كل حقلٍ بعدها. لذلك يُقصّ ما * بعد **آخر** قوسٍ مغلق لا أوّله؛ والخطأ في هذا لا يُكشَف إلّا بقتلٍ خاطئ. * EN: **A process's start time from the `/proc//stat` line, in clock ticks.** * * A pure function taking a string, **because what it does needs testing and cannot be tested by * reading `/proc`**: the cases that break it cannot be produced on demand on a machine. * * **And the name in parentheses may contain spaces and parentheses.** `proc(5)` puts the name * in field two between `(` and `)` with no escaping — so a process called `(my app)` or `a b c` * shifts every field after it. The cut is therefore after the **last** closing parenthesis, not * the first; getting it wrong surfaces only as a wrong kill. */ export declare function parseStartTicks(stat: string): number | undefined; //# sourceMappingURL=process-identity.d.ts.map