-   Programming (
-   -   dirver programming (

xiewanchen 05-19-2012 08:15 PM

dirver programming
when I call the funtion of kill_fasync() in the driver program, Why does this sentence "kill_fasync: bad magic number in fasync_struct!" was printed on the screen? Please explain it in details !

smallpond 05-22-2012 08:27 PM

That message is printed because there is a mistake in your code. Since you don't show any of your code it's hard to say more, but I've seen many problems caused by not checking return values from system calls.

xiewanchen 05-24-2012 06:46 AM

I have not shown any code because I don't know which section of the code is helpful for you to solve this problem. I can find this sentence which was printed on the screen in the kernel code.
static void kill_fasync_rcu(struct fasync_struct *fa, int sig, int band)
while (fa) {
struct fown_struct *fown;
unsigned long flags;

if (fa->magic != FASYNC_MAGIC) {
printk(KERN_ERR "kill_fasync: bad magic number in "
//this sentence is above !!!
spin_lock_irqsave(&fa->fa_lock, flags);
if (fa->fa_file) {
fown = &fa->fa_file->f_owner;
/* Don't send SIGURG to processes which have not set a
queued signum: SIGURG has its own default signalling
mechanism. */
if (!(sig == SIGURG && fown->signum == 0))
send_sigio(fown, fa->fa_fd, band);
spin_unlock_irqrestore(&fa->fa_lock, flags);
fa = rcu_dereference(fa->fa_next);

All times are GMT -5. The time now is 11:10 AM.