From owner-freebsd-current@FreeBSD.ORG Tue Sep 9 12:41:38 2008 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 122EB106564A for ; Tue, 9 Sep 2008 12:41:38 +0000 (UTC) (envelope-from kr.lekha@gmail.com) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.231]) by mx1.freebsd.org (Postfix) with ESMTP id DC0D98FC18 for ; Tue, 9 Sep 2008 12:41:37 +0000 (UTC) (envelope-from kr.lekha@gmail.com) Received: by rv-out-0506.google.com with SMTP id b25so2686184rvf.43 for ; Tue, 09 Sep 2008 05:41:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type:references; bh=XPZaIQsDgiGGVdpiUbmpwaIG/B+p9v/n3WjvOWbTtkk=; b=KuJz3mnYFGeo15b7ZYKnBJxqopIGeZ9smCGQJjngS/1FQBUBKnvVmHZAekRfekOmJF FBmLf8SSqQUkSj94La1RyVHw3fbw6MIkRnVyILBkUjAeFgkiEgUKp24+XWsgwO79Rwxn SJtcf5dcssqN1ShEcaWG0HpsWaaVIBW0pmd6A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:references; b=QmtHiAPoiPLNxMirfBsR57N6p2nixPJjw2J9ZBRCAaZ6ODvJH+LiRBwuMzaaNT/9in H+nlbgzeGNszNgo0VD5G1r5rGoZ+8wxrNuRY5xCeMuzc2AySmk0KktX6oPfpjwoKxpS0 9xlqoKsomsM4k/66oBtLHeKFDHF9mfk92RCaI= Received: by 10.141.49.6 with SMTP id b6mr9661401rvk.223.1220964097453; Tue, 09 Sep 2008 05:41:37 -0700 (PDT) Received: by 10.141.212.11 with HTTP; Tue, 9 Sep 2008 05:41:37 -0700 (PDT) Message-ID: <96b2ec350809090541x1035aae6qb59d47c9052ebf29@mail.gmail.com> Date: Tue, 9 Sep 2008 13:41:37 +0100 From: "kr Lekha" To: "John Baldwin" In-Reply-To: <200809081726.13043.jhb@freebsd.org> MIME-Version: 1.0 References: <96b2ec350809030232v5586ea44nf6ead7d856f72634@mail.gmail.com> <200809081726.13043.jhb@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-current@freebsd.org Subject: Re: Kthread kill X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Sep 2008 12:41:38 -0000 Hi all, thanks very much for your valuable inputs. I found out the way to exit the thread. Problem was psignal(p, SIGKILL); , the p->p_siglist was being reset after propagating this signal to threads associated with this proc. Hence i could poll once in a way if any unhandled signals were in curthread->td_siglist. I am not sure if this is the optimal solution. Please do sugest if you have a better solution Why cant we have signal handlers for kernel threads? when i tried to register one, sigaction returned value 14 and signal handler didnt get registered. Thanks, lekha On Mon, Sep 8, 2008 at 10:26 PM, John Baldwin wrote: > On Wednesday 03 September 2008 05:32:00 am kr Lekha wrote: > > Hi, > > i wanted to kill a kthread created by my module, There is no actual > > kthread_kill to kill it > > > > hence I tried to send kill signal to thread > > psignal(p, SIGTERM); > > psignal(p, SIGKILL); > > killproc(p,"messeage"); > > and kthread_suspend() > > > > Nothing seems to be killing the kthread, I still see it > > [root@ /usr/src]# ps awx -l | grep kernel > > UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME > > COMMAND 0 1048 1 0 20 0 0 8 ktsusp > > DL ?? 0:00.01 [new_kernel_thread] > > > > > > I have noticed that generally if kernel module wanted to kill a thread > then > > it calls > > { > > wakeup(p); > > msleep(p,0); /*or tsleep*/ > > } > > > > This puts the thread to sleep forever. However kthread_suspend also > > performs same actions. > > Your kthread has to explicitly check for a kill request in its main loop > and > call kthread_exit() or some such. There is no force-kill for kthreads. > > -- > John Baldwin >