From owner-freebsd-arch@FreeBSD.ORG Tue Mar 15 12:51:38 2005 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4C5B716A4CE for ; Tue, 15 Mar 2005 12:51:38 +0000 (GMT) Received: from darkness.comp.waw.pl (darkness.comp.waw.pl [195.117.238.136]) by mx1.FreeBSD.org (Postfix) with ESMTP id B5E5843D62 for ; Tue, 15 Mar 2005 12:51:37 +0000 (GMT) (envelope-from pjd@darkness.comp.waw.pl) Received: by darkness.comp.waw.pl (Postfix, from userid 1009) id 1F5A9ACBD6; Tue, 15 Mar 2005 13:51:36 +0100 (CET) Date: Tue, 15 Mar 2005 13:51:36 +0100 From: Pawel Jakub Dawidek To: freebsd-arch@freebsd.org Message-ID: <20050315125136.GH9291@darkness.comp.waw.pl> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="PbNjaMlpH3/3j4oy" Content-Disposition: inline User-Agent: Mutt/1.4.2i X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 5.2.1-RC2 i386 Subject: System processes recognition. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Mar 2005 12:51:38 -0000 --PbNjaMlpH3/3j4oy Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 =3D=3D NULL || argv[0] =3D=3D NULL), but this is not true: char *argv[1] =3D { NULL }; execve("/path/to/somewhere", argv, NULL); /path/to/somewhere process will be recognized by ps(1) as a system proces= s. 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 =3D p; =20 p->p_sysent =3D &null_sysvec; - p->p_flag =3D P_SYSTEM; + p->p_flag =3D P_SYSTEM | P_KTHREAD; p->p_sflag =3D PS_INMEM; p->p_state =3D PRS_NORMAL; knlist_init(&p->p_klist, &p->p_mtx); Opinions? --=20 Pawel Jakub Dawidek http://www.wheel.pl pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! --PbNjaMlpH3/3j4oy Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFCNtpYForvXbEpPzQRAkxKAJ467sqHyQxGbtCMVNQyO224C7otFACfZO6G ciQAJyoecbw3fmvJD85j76U= =yWsz -----END PGP SIGNATURE----- --PbNjaMlpH3/3j4oy--