Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Mar 2005 13:51:36 +0100
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        freebsd-arch@freebsd.org
Subject:   System processes recognition.
Message-ID:  <20050315125136.GH9291@darkness.comp.waw.pl>

index | next in thread | raw e-mail

[-- Attachment #1 --]
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
  (argv == NULL || argv[0] == NULL), but this is not true:
	char *argv[1] = { NULL };

	execve("/path/to/somewhere", argv, NULL);
  /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:

--- init_main.c	17 Feb 2005 10:00:09 -0000	1.255
+++ init_main.c	15 Mar 2005 12:48:04 -0000
@@ -365,7 +365,7 @@ proc0_init(void *dummy __unused)
 	session0.s_leader = p;
 
 	p->p_sysent = &null_sysvec;
-	p->p_flag = P_SYSTEM;
+	p->p_flag = P_SYSTEM | P_KTHREAD;
 	p->p_sflag = PS_INMEM;
 	p->p_state = PRS_NORMAL;
 	knlist_init(&p->p_klist, &p->p_mtx);

Opinions?

-- 
Pawel Jakub Dawidek                       http://www.wheel.pl
pjd@FreeBSD.org                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQFCNtpYForvXbEpPzQRAkxKAJ467sqHyQxGbtCMVNQyO224C7otFACfZO6G
ciQAJyoecbw3fmvJD85j76U=
=yWsz
-----END PGP SIGNATURE-----
help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050315125136.GH9291>