lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANudz+vvXrw=4+tk6z8GW+2rW-ZsogN0XGcozLSyY-dJ_SoHdw@mail.gmail.com>
Date:	Tue, 12 Jul 2011 01:57:20 +0800
From:	loody <miloody@...il.com>
To:	Chris Friesen <chris.friesen@...band.com>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: how to find a task through name faster?

hi:

2011/7/12 Chris Friesen <chris.friesen@...band.com>:
> On 07/11/2011 10:52 AM, loody wrote:
>>
>> hi all:
>> I found a way to find a task I need by name, test,  as below:
>> for_each_process(task) {
>>     if(strcmp(task->comm, "test")
>>         printk(“%s[%d]\n”, task->comm, task->pid);
>> }
>>
>> But it is time-consuming to do so if I periodically want to know
>> whether "test" exist or not.
>> is there better way to do so?

Thanks for your reply

> The names of tasks isn't indexed in any way so the above is about as good as
> it gets if that's all the information you have.

actually, I only have the name for searching, since the thread start
 and finish periodically, pid of it will change dynamically. If I save
the pid, next time it will change and be no use to me
>
> One common way around that is to store the PID in a file somewhere at
> startup.  Then you can look in the file and see if that PID is present and
> check "task->comm" to make sure it's what you expect.  This saves having to
> search through all tasks.
>
> Chris


-- 
Regards,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ