![]() |
|
|
|
|
|||||||
| 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 |
| Signal Problem | jacques83 | High Level Programming | 5 | 11-16-2006 09:30 PM |
| Signal question | GCTEII | Shell Programming and Scripting | 1 | 04-14-2006 03:46 AM |
| I have a problem using signal SIGUSR2 | khan_069 | UNIX for Advanced & Expert Users | 3 | 03-23-2006 03:35 PM |
| Signal Names | laila63 | High Level Programming | 2 | 11-03-2004 09:27 AM |
| [Problem] raise a signal in FreeBSD | Namely | High Level Programming | 1 | 11-08-2003 08:11 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
#include<signal.h>
void suicide(); main() { printf("use CTRL \\ for exiting \n"); //signal(SIGINT,SIG_DFL); signal(SIGQUIT,suicide); for (; } void suicide() { printf("hello here you r in the suicide code "); } i was just starting with signals .. and tried this ,, but in the above i am calling suicide function in the signal function , its not working why ?? also the default behavior of the <ctrl \ > is being suppressed . can you tell me why it is so ,, and when i tried it passing SIG_DFL it worked .. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
put this in suicide
Code:
void suicide(int num)
{
write(1,"suicide\n",8);
}
|
|
#3
|
|||
|
|||
|
ya a \n in the printf worked ,, Porter ,, can you tell me what was the problem ,, and now pressing CTRL \ first time is printing the message ,, but pressing it for the second time must quit it , i e the default action must be performed ,, but it is again printing the message ..???
|
|
#4
|
|||
|
|||
|
if stdout is connected to a terminal then it does not fflush until a newline is written.
some operating systems require the signal handler to be reinstalled after calling, eg Code:
void suicide(int num)
{
... set flags etc ....
signal(num,suicide);
}
|
|
#5
|
|||
|
|||
|
thanks porter .. i m using fedora core 7 ,,it seems that it doesn't need the signal handler to be called again.
|
|
#6
|
|||
|
|||
|
why the second printf in main is being executed after pressing CTRL \
#include<stdio.h>
#include<signal.h> void suicide(); main() { printf("use CTRL \\ for exiting \n"); printf("iiiiiiiiiiiiiis"); //signal(SIGINT,SIG_DFL); signal(SIGQUIT,suicide); for (; } /*void suicide() { printf("hello here you r in the suicide code\n "); }*/ void suicide(int num) { printf("hii u r in suicide\n"); } why the second printf in main is being executed after pressing CTRL \ . the iiiiiiiis is being printed only after i m pressing CTRL \ ,, #include<stdio.h> main() {printf("hello u\n"); printf("hello how r yu again "); } while here both the print statements are being executed in one go .. ??? |
|
#7
|
|||
|
|||
|
Quote:
It is dependent on the semantics of the signal used, whether older semantics is used or the newer semantics. Once the function registered for signal handler is executed, the function has to be re-registered again to ensure that the function is executed when a signal of same type is received again This is not needed with newer semantics, no need for re-registering it again and again. |
|||
| Google The UNIX and Linux Forums |
| Tags |
| linux |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|