From: srivatsa.bhat@linux.vnet.ibm.com (Srivatsa S. Bhat)
To: kernelnewbies@lists.kernelnewbies.org
Subject: SIGKILL and a sleeping kernel module
Date: Tue, 19 Feb 2013 14:46:16 +0530 [thread overview]
Message-ID: <512342E0.6000205@linux.vnet.ibm.com> (raw)
In-Reply-To: <CAGXs5wVG1N1RcVviPPvhjJ553cvQzGErvjihAtRmdqC7WhtOCw@mail.gmail.com>
On 02/19/2013 02:07 PM, Kevin Wilson wrote:
> Hi all,
> I am trying to send a SIGKILL to a kernel module which is sleeping.
> I added a printk after the sleep command.
> Sending a SIGLKILL (by kill -9 SIGLKILL pidOfKernelThread) does **not**
> yield the message from printk("calling do_exit\n");
> which is immediately after the msleep() command, as I expected.
>
> Moreover, ps before and after the kill show 'D' in the STAT column
> (STATUS), which means that the process is sleeping (If I am not
> wrong).
>
> Any ideas why ?
There are 2 ways in which a task can sleep - interruptible sleep and
uninterruptible sleep. Interruptible sleep means, the task can get
interrupted by a signal. A task doing uninterruptible sleep doesn't
get woken up by any signal. The 'D' state indicates that the task is
doing uninterruptible sleep, that's why your signals aren't working.
Regards,
Srivatsa S. Bhat
> below is the code:
>
> #include<linux/init.h>
> #include<linux/module.h>
> #include<linux/kernel.h>
> #include<linux/kthread.h>
> #include<linux/sched.h>
> #include <linux/delay.h>
>
> struct task_struct *task;
>
> int thread_function(void *data)
> {
> int exit_sig = SIGKILL;
>
> allow_signal(SIGKILL);
>
> printk("in %s\n",__func__);
> // sleep for a second
> msleep(60000);
> printk("calling do_exit\n");
> do_exit(exit_sig);
>
> return 0;
> }
>
> static int kernel_init(void)
> {
> task = kthread_create(thread_function,NULL,"MY_KERNEL_THREAD");
> return 0;
> }
>
> static void kernel_exit(void)
> {
> printk("in kernel_exit\n");
> kthread_stop(task);
> }
>
>
> module_init(kernel_init);
> module_exit(kernel_exit);
>
> MODULE_AUTHOR("Tester");
> MODULE_DESCRIPTION("test");
> MODULE_LICENSE("GPL");
>
> rgs,
> Kevin
>
next prev parent reply other threads:[~2013-02-19 9:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-19 8:37 SIGKILL and a sleeping kernel module Kevin Wilson
2013-02-19 9:11 ` Silviu Popescu
2013-02-19 9:16 ` Srivatsa S. Bhat [this message]
2013-02-19 11:32 ` Kevin Wilson
[not found] ` <5123643C.1000907@linux.vnet.ibm.com>
2013-02-19 12:00 ` Kevin Wilson
2013-02-19 18:55 ` Mulyadi Santosa
2013-02-20 6:29 ` Srinivas Ganji
2013-02-20 6:33 ` Srinivas Ganji
2013-02-19 19:54 ` Anatol Pomozov
2013-02-19 10:33 ` Valdis.Kletnieks at vt.edu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=512342E0.6000205@linux.vnet.ibm.com \
--to=srivatsa.bhat@linux.vnet.ibm.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.