Re: Checking status of userspace processes

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

 



On Wed, Oct 21, 2009 at 3:07 PM, Leonidas . <leonidas137@xxxxxxxxx> wrote:
> On Thu, Oct 22, 2009 at 12:26 AM, Leonidas . <leonidas137@xxxxxxxxx> wrote:
>> What would be an ideal way to check if a process/thread is running or sleeping
>> or it is dead from kernel space?
>>
>> Basically, check whether a process is alive, then determine its status.
>>
>> -Leo.
>>
>
> E.g. My module wants to do some cleanup after a thread exits after calling
> pthread_exit(). The only way my module can know about it by looking in to list
> of processes but this is not a foolproof since the pid can be recycled.
>
>
> -Leo.
>

Hi Leo,

I never did this, but I found it on the internets, so it must be ok ...

<quote>
task_t *p;
read_lock(&tasklist_lock);
for_each_process(p) {
  if ( strcmp (p->comm, $your-daemon-name) == 0)
    break;
}
read_unlock(&tasklist_lock);

sounds not a good idea. Smile
</quote>

But, maybe it gives you some ideas?

-bob

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux