bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#68800: Guix waits for termination of a kernel thread


From: Ludovic Courtès
Subject: bug#68800: Guix waits for termination of a kernel thread
Date: Tue, 20 Feb 2024 11:08:15 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Hi Tomas,

Tomas Volf <~@wolfsden.cz> skribis:

>> What about this method (from shepherd)?
>>
>> --8<---------------cut here---------------start------------->8---
>> (define (linux-process-flags pid)
>>   "Return the process flags of @var{pid} (or'd @code{PF_} constants), 
>> assuming
>> the Linux /proc file system is mounted; raise a @code{system-error} exception
>> otherwise."
>>   (call-with-input-file (string-append "/proc/" (number->string pid)
>>                                        "/stat")
>>     (lambda (port)
>>       (define line
>>         (get-string-all port))
>>
>>       ;; Parse like systemd's 'is_kernel_thread' function.
>>       (let ((offset (string-index line #\))))     ;offset past 'tcomm' field
>>         (match (and offset
>>                     (string-tokenize (string-drop line (+ offset 1))))
>>           ((state ppid pgrp sid tty-nr tty-pgrp flags . _)
>>            (or (string->number flags) 0))
>>           (_
>>            0))))))
>>
>> ;; Per-process flag defined in <linux/sched.h>.
>> (define PF_KTHREAD #x00200000)                    ;I am a kernel thread
>>
>> (define (linux-kernel-thread? pid)
>>   "Return true if @var{pid} is a Linux kernel thread."
>>   (= PF_KTHREAD (logand (linux-process-flags pid) PF_KTHREAD)))
>> --8<---------------cut here---------------end--------------->8---
>>
>> If it works better, we can use that in syscalls.scm as well.
>
> Yes, that does seem to work:

Pushed as 34c79c6ae8103ebae9ce08c81a9220a6b82b05f6.

Thank you!

Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]