From owner-freebsd-arch@FreeBSD.ORG Tue Mar 15 22:07:08 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 971CB16A4CE; Tue, 15 Mar 2005 22:07:08 +0000 (GMT) Received: from smtp3.server.rpi.edu (smtp3.server.rpi.edu [128.113.2.3]) by mx1.FreeBSD.org (Postfix) with ESMTP id A09F743D2F; Tue, 15 Mar 2005 22:07:04 +0000 (GMT) (envelope-from drosih@rpi.edu) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by smtp3.server.rpi.edu (8.13.0/8.13.0) with ESMTP id j2FM71Eo025283; Tue, 15 Mar 2005 17:07:01 -0500 Mime-Version: 1.0 Message-Id: In-Reply-To: <20050315125136.GH9291@darkness.comp.waw.pl> References: <20050315125136.GH9291@darkness.comp.waw.pl> Date: Tue, 15 Mar 2005 17:07:00 -0500 To: Pawel Jakub Dawidek , freebsd-arch@freebsd.org From: Garance A Drosihn Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-CanItPRO-Stream: default X-RPI-SA-Score: undef - spam-scanning disabled X-Scanned-By: CanIt (www . canit . ca) on 128.113.2.3 Subject: Re: System processes recognition (Adding P_KTHREAD to swapper) 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 22:07:08 -0000 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