From owner-freebsd-arch@FreeBSD.ORG Wed Mar 16 22:48:20 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 A0AE216A4CE for ; Wed, 16 Mar 2005 22:48:20 +0000 (GMT) Received: from mail24.sea5.speakeasy.net (mail24.sea5.speakeasy.net [69.17.117.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3A5DC43D39 for ; Wed, 16 Mar 2005 22:48:20 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: (qmail 5349 invoked from network); 16 Mar 2005 22:48:19 -0000 Received: from server.baldwin.cx ([216.27.160.63]) (envelope-sender )AES256-SHA encrypted SMTP for ; 16 Mar 2005 22:48:18 -0000 Received: from [10.50.40.202] (gw1.twc.weather.com [216.133.140.1]) (authenticated bits=0) by server.baldwin.cx (8.13.1/8.13.1) with ESMTP id j2GMm5Ku002222; Wed, 16 Mar 2005 17:48:08 -0500 (EST) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: freebsd-arch@FreeBSD.org Date: Wed, 16 Mar 2005 17:48:02 -0500 User-Agent: KMail/1.6.2 References: <20050315125136.GH9291@darkness.comp.waw.pl> In-Reply-To: <20050315125136.GH9291@darkness.comp.waw.pl> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200503161748.02353.jhb@FreeBSD.org> X-Spam-Status: No, score=-102.8 required=4.2 tests=ALL_TRUSTED, USER_IN_WHITELIST autolearn=failed version=3.0.2 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on server.baldwin.cx cc: Pawel Jakub Dawidek Subject: Re: 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: Wed, 16 Mar 2005 22:48:20 -0000 On Tuesday 15 March 2005 07:51 am, 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 > (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? I think this is ok. Ask bde@, he might say that P_SYSTEM should be removed from init. (Can't remember if he is in favor of that or not.) -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org