LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-08-2012, 11:49 PM   #1
sindhu4sind
Member
 
Registered: Apr 2012
Posts: 38

Rep: Reputation: Disabled
Sending Signals in kernel


Hello everyone,

I am trying to communicate and receive a message from kernel module when a condition occurs.
I am using Ubuntu 8.04

KERNEL MODULE CODE:
Quote:

..
static pid_t id;
int result;
..
int network_response()
{
...
...
if (x = 1)
{
printk("Failure of network.")
result = kill_proc(id, SIGUSR1,1);
printk("\nReporting failure detection %d\n", result);

}
if (x = 2)
{
printk("Failure of Node is detected.")
result = kill_proc(id, SIGUSR1,1);
printk("\nReporting failure detection %d\n", result);

}
}
And user APplication code (Sorry pasting full code because i have confusion here):
Quote:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <linux/types.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <signal.h>

#include "safe_def.h"
#include "pmn.h"

int sig;

void usrSignal(int signo);

int main (void){
welcome_msg();

pid_t id;
int quit =1;

(void)signal(SIGUSR1, usrSignal);
printf ("Caught the user Signal %d\n",sig);
id = getpid();

// gSafeSock = socket (AF_INET, SOCK_RAW, IPPROTO_RAW);
//ioctl (gSafeSock, SIOCGIFFLAGS, &id);


//int result = (void)signal(SIGUSR1, usrSignal);
//ioctl (result, SIOCGIFFLAGS, &id);


ioctl (SIOCGIFFLAGS, &id);

sig = printf("\nMy PID is : %d\n\n", id);


safe_module_connect();
safe_module_get_host_info();
safe_module_get_net_info();

while (quit) {
if (sig < 0){
printf("Exit Program %d", sig);
quit = 0;
}
}
return 0;
}


void usrSignal(int signo) {
sig = signo;
printf("Function usrSignal Called");
if (sig == SIGUSR1)
printf("Received SIGUSR1 successfully\n");
else
printf("Error: In Receieving Signal %d\n", sig);
(void)signal(SIGUSR1, usrSignal);
return ;

}
Can you please tell me that What i have to do in order to receive signals from Kernel module, because in that way i am unable to get reply..
or if any thing i am missing in my implementation then please notify it to me..

I am a newbie so sorry if my code or explanation is not so good..

Sindhu
 
Old 05-09-2012, 10:18 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,944

Rep: Reputation: 7324Reputation: 7324Reputation: 7324Reputation: 7324Reputation: 7324Reputation: 7324Reputation: 7324Reputation: 7324Reputation: 7324Reputation: 7324Reputation: 7324
duplicate of http://www.linuxquestions.org/questi...-space-943290/
 
  


Reply

Tags
kernel module, signal handler



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending Signals from one program to several others in C/C++ on SL6.0 jlabbesstl Linux - Software 2 08-17-2011 10:19 AM
Rexec and sending signals to the remote process. oyhaare Programming 0 03-15-2011 08:06 AM
Sending SIGKILL/signals to process and all children? thecake Linux - Newbie 1 12-22-2008 04:50 PM
sending signals jiya_31 Linux - Software 3 10-25-2007 03:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration