Visit Our UNIX and Linux User Community


add more user-defined signals


 
Thread Tools Search this Thread
Top Forums Programming add more user-defined signals
# 1  
Old 07-20-2010
add more user-defined signals

Hi

Is there a way to add more user-defined signals?
I am currently using SIGUSR1 and SIGUSR2 - but I need another one.
How can I do that?

Thanks!
# 2  
Old 07-20-2010
The signals are defined in the POSIX standard (IEEE Std 1003.1-2001), and implemented in the kernel. Unless you want to break compatibility with all other Unices I'd advise using other methods of IPC, eg messages via shared memory.
# 3  
Old 07-20-2010
Unfortunately, there is no way to add signals. If you don't want to use other forms of IPC (you should look into this if you're likely to add more signals - a named pipe that accepts a line telling it what action to take is quite common) you can "hijack" one of the other ones. SIGHUP is quite commonly used to indicate a program should reload all/part of its config, so that's one that won't cause too much surprises (especially if you use it for that express purpose).
# 4  
Old 07-20-2010
1) In case I "take over" SIGHUP signal, can I use the "kill" function in order to raise it?
kill(pid, SIGHUP);
and the signal function in order to catch it on the other side?
signal(SIGHUP, sig_handler)

2) Just to make sure I understand the second you were talking about (IPC messages / named pipe) it requires both processes to "pull" from the shared memory the details and don't have something to wake the process (or in other words- it doesn't signal the process) right?
If so, that doesn't help me...
# 5  
Old 07-20-2010
Quote:
Originally Posted by naamabm
1) In case I "take over" SIGHUP signal, can I use the "kill" function in order to raise it?
kill(pid, SIGHUP);
and the signal function in order to catch it on the other side?
signal(SIGHUP, sig_handler)
Yes - there is no real difference between SIGUSR1/SIGUSR2 and SIGHUP - you can kill() them in exactly the same way, and you set up the signal handler with signal() in the same way.


Quote:
Originally Posted by naamabm
2) Just to make sure I understand the second you were talking about (IPC messages / named pipe) it requires both processes to "pull" from the shared memory the details and don't have something to wake the process (or in other words- it doesn't signal the process) right?
If so, that doesn't help me...
I'm not sure about what you mean by "pull" from shared memory - there's certainly no requirement to actually use any shared memory. Both processes will need to know the name of the pipe. While it doesn't technically speaking "signal" the process, you can make a blocking read() from the pipe, and you're blocked until someone writes to it/there's an error, so your program will sit dormant until there's something to do.
# 6  
Old 07-20-2010
Pick another signal - one that will not be raised by any of the system calls, one that you can block.

This is by no means guaranteed to work. If your system supports realtime signals you can look into those as well. They may be called something like RTMIN or RTMAX.

kill -l ( that is the letter L lowercase) lists all of the signals on your system.
# 7  
Old 07-20-2010
If your system has realtime signals, you can use them. SIGRTMIN, SIGRTMIN+1, ..., SIGRTMAX are signals with no predefined meaning. Note that the first two are already used in older Linux systems for thread management, so avoid them.

Previous Thread | Next Thread
Test Your Knowledge in Computers #931
Difficulty: Medium
64-bit computer system storage allocation for timekeeping will allow them to represent dates more than 300 billion years into the future.
True or False?

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

user defined commands

Hi, i would like to create user defined commands. e,g: if an user executes , mkdircd test then a directory called test should be created and it should be cd to test. How i can create the command mkdircd with below action: mkdir $1 && cd $1. Please help me in achieving this (7 Replies)
Discussion started by: pandeesh
7 Replies

2. Shell Programming and Scripting

User defined functions in awk

Hi; Is der ne to to use user defined functions for the values in awk find $1 -type f -ls | nawk '{{print "|"$3"|"$5"|"$6"|"$8"|"$9"|"$10"|"} for(i=11;i<=NF;i++){printf("%s",$i)}}' In above command i want to append some values returned by user functions on line. thnks; ajay (1 Reply)
Discussion started by: ajaypadvi
1 Replies

3. Programming

how to add user defined tag in a mp3 file?

Hai all, Can anyone explain me about how to add an user defined tag in an mp3 file using MP3::Tag module in perl? (0 Replies)
Discussion started by: thillai_selvan
0 Replies

4. Shell Programming and Scripting

Unable to add user defined variable

Hi, I have a user defined variable _TIME1=xxx I am using awk command for pattern matching. cat $_LOCATION/catalina.txt | awk '/^`$_TIME1`:??:??/' It not taking the value of $_TIME! eg:I am using the command to get all the patter from 12:00:00 to 12:59:59 The user defined variable... (2 Replies)
Discussion started by: ahamed
2 Replies

5. Solaris

Wants to use User defined Macro in Makefile

I am converting 32-bit C++ code to 64-bit on Solaris. I have used unsigned long in number of files. I want it to convert to unsigned int for 64-bit. Total files are around 2000. Can you please help me if possible to do it in makefile using MACRO while build. If it is not possible any other... (2 Replies)
Discussion started by: amit_27
2 Replies

6. Shell Programming and Scripting

need help with User Defined Function

Dear Friends, I need a help regarding User defined function in shell script. My problem is as follows: my_func.sh my_funcI(){ grep 'mystring' I.dat } my_funcQ(){ grep 'mystring' Q.dat } myfuncI myfuncQ But As both the function has same function only the... (11 Replies)
Discussion started by: user_prady
11 Replies

7. UNIX for Dummies Questions & Answers

User defined service

I want to add a new IP service which executes a script on SCO OS5. I have amended /etc/services and added to port number (3333) I have amended /etc/inetd.conf and added a line for this service but I can't get it to execute my own shell script When I telnet to the IP address on port 3333 I... (1 Reply)
Discussion started by: markdrury
1 Replies

8. AIX

User defined signal 1

Hi, I am just running a incremental back-up on one of my server. But these days It abrubtly fails with below error. ========== User defined signal 1 =========== When I rerun the back-up, It completed successfully.Earlier this was not happening. Any Idea, what could be the problem... (0 Replies)
Discussion started by: nitesh_raj
0 Replies

9. Shell Programming and Scripting

Nawk user-defined function

HELP!!!! I am in an on-line shell programming class and have a question. Here is the data: Mike Harrington:(510) 548-1278:250:100:175 Christian Dobbins:(408) 538-2358:155:90:201 Susan Dalsass:(206) 654-6279:250:60:50 (There are 12 contribuors total) This database contains names, phone... (1 Reply)
Discussion started by: NewbieGirl
1 Replies

Featured Tech Videos