LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 12-11-2005, 08:53 AM   #1
YaK.
LQ Newbie
 
Registered: Nov 2005
Posts: 6

Rep: Reputation: 0
How to use SIGUSR1 and SIGUSR2


Hello,
I've already searched in google and man pages but I don't understand how to use SIGUSR1 and SIGUSR2.

I read somewhere that it is possible to make a subprocess with fork(), then pause the subprocess and wake it up by sending a signal (with SIGUSR1 or SIGUSR2) at some other point of the program. How could I do this?
I know how to make subprocesses but I don't know how to program a signal with SIGUSR1 and how wake up the subprosses with that signal.

Thx for help
 
Old 12-11-2005, 09:16 AM   #2
skie_knite007
Member
 
Registered: Dec 2004
Location: India
Distribution: Fedora Core 4
Posts: 145

Rep: Reputation: 15
I will illustrate with an example:

say u need to create an user defined signal SIGUSR1.....

I'm considering a child process..

//Child context (consider it needs to send a kill signal to parent)

kill(getppid(),SIGUSR1);

//parent context

signal(SIGUSR1,your_signal_handler)



In this the kill signal is sensed by the parent ( as SIGUSR1)

if u need to use one more signal use it as SIGUSR2.
 
Old 12-11-2005, 10:41 AM   #3
YaK.
LQ Newbie
 
Registered: Nov 2005
Posts: 6

Original Poster
Rep: Reputation: 0
ah, thanks a lot.

Another question: is it possible to send other signals than the kill signal or is that the only one?
 
Old 12-11-2005, 06:18 PM   #4
zahadumy
Member
 
Registered: May 2005
Location: Cluj, Romania
Distribution: Fedora Core 6
Posts: 226

Rep: Reputation: 31
Quote:
Originally Posted by YaK.
Another question: is it possible to send other signals than the kill signal or is that the only one?
Code:
kill(pid,SIGUSR1);
this sends SIGUSR1 to the process with pid given as parameter. Instead of SIGUSR1, you can send SIGKILL, SIGSTOP, etc.
 
  


Reply


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



All times are GMT -5. The time now is 09:42 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration