Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 05-09-2012, 12:49 AM   #1
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


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):
#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){

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);


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");
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..

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

Rep: Reputation: 7246Reputation: 7246Reputation: 7246Reputation: 7246Reputation: 7246Reputation: 7246Reputation: 7246Reputation: 7246Reputation: 7246Reputation: 7246Reputation: 7246
duplicate of


kernel module, signal handler

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 11:19 AM
Rexec and sending signals to the remote process. oyhaare Programming 0 03-15-2011 09:06 AM
Sending SIGKILL/signals to process and all children? thecake Linux - Newbie 1 12-22-2008 05:50 PM
sending signals jiya_31 Linux - Software 3 10-25-2007 04:59 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:51 PM.

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