Date: Tue, 15 Mar 2005 17:07:00 -0500 From: Garance A Drosihn <drosih@rpi.edu> To: Pawel Jakub Dawidek <pjd@freebsd.org>, freebsd-arch@freebsd.org Subject: Re: System processes recognition (Adding P_KTHREAD to swapper) Message-ID: <p06210202be5d09b2ca17@[128.113.24.47]> In-Reply-To: <20050315125136.GH9291@darkness.comp.waw.pl> References: <20050315125136.GH9291@darkness.comp.waw.pl>
index | next in thread | previous in thread | raw e-mail
At 1:51 PM +0100 3/15/05, Pawel Jakub Dawidek wrote:
>Hi.
>
>I found, that there is no way to know if the given process is a system
>(kernel) process or not:
>
>- P_SYSTEM flag is used also for userland processes (init),
>- P_KTHREAD flag is not used for swapper,
>- ps(1) thinks, that it found system process when there are
> no arguments, checking: (argv == NULL || argv[0] == NULL)
> but this is not true:
>
> char *argv[1] = { NULL };
> execve("/path/to/somewhere", argv, NULL);
>
> The /path/to/somewhere process will be recognized by ps(1)
> as a system process.
>
>The easiest way to fix it, is to add P_KTHREAD flag to the
>swapper, I think:
Something like this would be helpful, but I don't know enough
kernel-stuff to know if there would be any side-effects by
setting that bit. If that doesn't work, then we could have
pkill/pgrep/ps check for 'pid == 0 && uid == 0', and assume
any process that matches is also a "kernel thread process".
But obviously it would be cleaner if we could just set that
bit on the swapper process... I suppose I could just try that
on a test system, and see if the system goes haywire :-)
--
Garance Alistair Drosehn = gad@gilead.netel.rpi.edu
Senior Systems Programmer or gad@freebsd.org
Rensselaer Polytechnic Institute or drosih@rpi.edu
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p06210202be5d09b2ca17>
