![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| CEP: What about the action? | iBot | Complex Event Processing RSS News | 0 | 02-15-2008 08:20 AM |
| tracking user action | xitrum | UNIX for Advanced & Expert Users | 7 | 03-07-2007 01:48 PM |
| action command | esham | Shell Programming and Scripting | 5 | 07-30-2005 01:04 AM |
| action based on rsync status | dangral | UNIX for Dummies Questions & Answers | 2 | 04-29-2005 09:25 AM |
| any idea to repeat a action in VI | myelvis | UNIX for Dummies Questions & Answers | 6 | 11-26-2003 03:21 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Signal Default Action
Code:
#include <signal.h>
void handler(int sig) {
int i;
for( i=0; i<=999999; i++ ) {
}
printf("Received signal: %d\n", sig);
}
int main() {
signal(SIGINT, handler);
while (1) {
}
return 0;
}
Its not happening so, each time a SIGINT is delivered, handler is executing without any problems. Any thoughts on this ? |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Surprisingly
it works as expected in solaris and hp - that is terminate when the second SIGINT is delivered but not in Linux ( RHEL3 ) Could there be any difference in the signal standards ? Code:
uname -a Linux 2.4.21-37a8 |
|
#3
|
||||
|
||||
|
Resetting the handler is dumb. That is the original behavior, but during the window between the automatic reset and the reinstallation of the handler, a signal can be lost. So BSD changed signal(). On HP-UX, you can get either behavior by linking with different libraries. Anyway, both behaviors were in use when Posix came along. So, according to the Posix standard:
Quote:
Quote:
|
|
#4
|
|||
|
|||
|
Quote:
Am just curious to know about the behavior of signal(); and why its behavior is different in different systems. Is it due to the reason that different libraries are in use ? If so, how to identify them ? Quote:
In that case, there is no reason for it to wait till the function block is executed. In short, can it be said signal() behavior is undefined - or am I being rude in saying that ? |
|
#5
|
||||
|
||||
|
Quote:
Quote:
|
|
#6
|
|||
|
|||
|
I would use the term "platform dependent".
Use sigaction() and you will get rewards in this life as well as the next from the Great God Posix. In Visual C++ you have to reinstall the signal handler in order to catch it again. |
|
#7
|
|||
|
|||
|
Quote:
As I could see the difference when executing the same code in HP, Solaris, RHEL3. - Different behavior Porter, is this what you meant ? |
|||
| Google The UNIX and Linux Forums |