Query on signal delay


 
Thread Tools Search this Thread
Top Forums Programming Query on signal delay
# 1  
Old 10-07-2011
Query on signal delay

Hi
I have used setitmer function in C to notify the occurence of an event .
setitimer function generates a SIGLALRM signal which I handled through a
defined handler using signal system call.
There are multiple processes running and using this handler to handler the
SIGALRM .
The handler is defined in a class in a separate file and being used in
different processes creating local objects.
I noticed that there is a delay in calling the handler for a process ..as
the signal is generated on time .
Could anyone help and tell the reason for this behaviour ..
I read that when a process receives a signal the kernel blocks further
receipt of the signal until the signal handler completes
So according to this if multiple signals occur on after the other ,both
gets blocked ?
If yes then how they get handled at a later time ..
Regards,
Ankit

Last edited by fpmurphy; 10-10-2011 at 09:44 PM.. Reason: removed duplicate text
# 2  
Old 10-10-2011
I suggest you "man 7 signal" and "man sigaction".

However, it sounds like what you're trying to do is probably best accomplished without signals; possibly better left to something like an event library (google libevent).

edit: to be more helpful; let me break down your post:

Quote:
Originally Posted by anktim
Hi
I have used setitmer function in C to notify the occurence of an event .
setitimer function generates a SIGLALRM signal which I handled through a
defined handler using signal system call.
There are multiple processes running and using this handler to handler the
SIGALRM .
Fine.
Quote:
Originally Posted by anktim
The handler is defined in a class in a separate file and being used in
different processes creating local objects.
Take a long and hard read about async signal safe functions. You may not want to do as much work as you're doing in that signal handler.
Quote:
Originally Posted by anktim
I noticed that there is a delay in calling the handler for a process ..as
the signal is generated on time .
Could anyone help and tell the reason for this behaviour ..
Nope...but I'm not surprised the timer may not be as precise as you want.
Quote:
Originally Posted by anktim
I read that when a process receives a signal the kernel blocks further
receipt of the signal until the signal handler completes
So according to this if multiple signals occur on after the other ,both
gets blocked ?
If yes then how they get handled at a later time ..
Regards,
Ankit
True, depending on how you install the signal handler. And, since signals don't have to be delivered, if it's blocked and another signal is queued up and delivered, it could be ignored. In other words, if I run a process and just fire the alarm signal into it (kill -alrm <pid>) over and over rapidly, it's not going to queue up all those signals and then call your handler all those times. It'll queue up one (maybe) and drop all the rest. Make sense?

Last edited by DreamWarrior; 10-10-2011 at 06:16 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Trying to understand the delay

Heyas As you know me, i have scripts for about almost every aspect of my IT life. This time, i'm having issues to figure out why my script to connect to my wifi spots takes so long when started as service. The service file (the after:local-fs.target is for 'home installations'): cat... (3 Replies)
Discussion started by: sea
3 Replies

2. Shell Programming and Scripting

Loop without a delay

Hi, I am trying to understand what would happen if ther is a loop without any delay like sleep statement, I feel that would add a lot of load onto the CPU. Trying to understand how the load is reduced by the introduction of sleep(). Thanks and regards Zulfi (3 Replies)
Discussion started by: zulfi123786
3 Replies

3. UNIX for Dummies Questions & Answers

Delay with Wget

I have a list of URLs that I need to download in a file. I know I can use the -i option to load the URLs from the file, but how can I make Wget wait a couple secs between each URL download? (4 Replies)
Discussion started by: rlopes
4 Replies

4. Shell Programming and Scripting

Shell Script to execute Oracle query taking input from a file to form query

Hi, I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database. For instance: USER CITY --------- ---------- A CITY_A B CITY_B C ... (2 Replies)
Discussion started by: DevendraG
2 Replies

5. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

6. Shell Programming and Scripting

while loop and delay

Dear all, if we want to run a command every 5 mins to check if the process is working fine or not... like in c, we can use a simple while loop with a delay for 5 mins... how can we accomplish this is solaris 8/9 thanks br/asad (5 Replies)
Discussion started by: asadlone
5 Replies

7. Programming

Delay a process.

How to delay a process. I need to to delay a process from 3sec. At that 3sec other back ground processes also should stop. (just sit 3sec for idle & then starts execution as normally) I use sleep(3)-But it not stop the bg processes I try to use loop but it not gurantee to wait 3sec. ... (2 Replies)
Discussion started by: ugp
2 Replies

8. Programming

Introducing Delay less then a second.

Hi, I have a doubt in introducing a delay in the programs. We know that we do have a sleep() function/api using which we can bring a delay in terms of seconds. A minimum delay can be atleast 1 second. Now I'm bothered about how to introduce a delay that is just less than a second. Like... (3 Replies)
Discussion started by: S.Vishwanath
3 Replies

9. UNIX for Dummies Questions & Answers

Delay in mv

Working on AIX 4.3 I have an active exe that accepts files for processing on our RS6000. Day to day i store these files in a secure place and at the end of the day I mv them one by one. After some reading and ofcourse trial and error i figured out that this helps... mv `ls -l |head -l | awk... (2 Replies)
Discussion started by: buRst
2 Replies

10. UNIX for Dummies Questions & Answers

Login Delay

When telneting to a SUN box and incorrectly spelling your password, there is a delay of approx. 5 seconds. Is there any way to shorten this time? OS solaris 7 (1 Reply)
Discussion started by: SmartJuniorUnix
1 Replies
Login or Register to Ask a Question