Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751750AbZJWINf (ORCPT ); Fri, 23 Oct 2009 04:13:35 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751543AbZJWIN2 (ORCPT ); Fri, 23 Oct 2009 04:13:28 -0400 Received: from smtprelay08.ispgateway.de ([80.67.31.31]:46964 "EHLO smtprelay08.ispgateway.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751305AbZJWINY (ORCPT ); Fri, 23 Oct 2009 04:13:24 -0400 Message-ID: <4AE165A4.70706@ladisch.de> Date: Fri, 23 Oct 2009 10:13:24 +0200 From: Clemens Ladisch User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: "Leonidas ." CC: linux-kernel Subject: Re: Process id recycling and status of tasks References: In-Reply-To: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Df-Sender: linux-kernel@cl.domainfactory-kunde.de Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1015 Lines: 27 Leonidas . wrote: > 1. What would be an ideal way to check if a task is alive or dead from > kernel space? Get a reference to the task's pid (call get_task_pid(), or get_pid() on the return value of task_pid()), then later check whether pid_task() works. (pid_alive() is not what you want because this would require that you hold a reference to the task_struct.) > even though a certain pid might exist, it might have got recycled by > the time I check again, right? The functions above do not work with PID numbers but with struct pid which is a reference-counted object. (The functions with "get" in their name increase the reference count, so don't forget to put_pid() when you no longer need it.) See also the big comment in include/linux/pid.h. HTH Clemens -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/