JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi sociology physics physical education maths english economics geography History

chemistry business studies biology accountancy political science

Class 12

Hindi physics physical education maths english economics

chemistry business studies biology accountancy Political science History sociology

Home science Geography

English medium Notes

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Class 12

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Categories: c++ language in hindi

Signal Handling in c++ language , what is Signal Handling in hindi source code program

what is Signal Handling in hindi source code program , Signal Handling in c++ language :-
SIGQUIT:
इस signal का use किसी प्रोसेस को terminate करने के लिए  use किया जाता है | इसमें core dump को  generate किया  जाता है |
SIGTRAP:
इस signal का use किसी ट्रैप को trace करने के लिए  use किया जाता है | इसमें core dump को  generate किया  जाता है |
SIGBUS:
इसका use किसी  BUS error को find आउट करने के लिए किया जाता है इसके लिए invalid address को access करने के use किया जाता है BUS का use किसी दो सिस्टम devices मे communication करने के लिए किया जाता है | और अगर BUS मे कोई error आ जाती है तब SIGBUS generate होत्या है |
SIGUSR1:
इसका use User-defined signal 1 generate करने के लिए किया जाता है |
SIGUSR2:
इसका use User-defined signal 2 को generate करने के लिए किया जाता है |
SIGALRM:
इस signal का use Alarm clock को  generate करने के लोइए किया जाता है  Alarm clock expiration of a timer को indicate करता है |. इसके लिए अलार्म() को use किया जाता है |
SIGTERM:
इस signal का use किसी प्रोग्राम को terminate करने के लिए किया जाता है |इस  signal को  blocked, handled और ignored किया जा सकता है | इसे किल command से generate किया जा सकता है |SIGINT and SIGQUIT
नीचे दिए गये प्रोग्राम मे , दो यूजर define signal SIGINT and SIGQUIT को generate किक्या गया है | इस दोनों function से एक ही memory space को access किया जाता है |
The SIGINT handler : इस signal का use, किसी message को display करने के लिए किया जाता है जिसका use , SIGINT signal के मिलने पर प्राप्त होता है |}
The SIGQUIT handler : इस signal का use, किसी message को display करने के लिए किया जाता है जिसका use , SIGQUIT signal के मिलने पर प्राप्त होता है |
code :
#include  <stdio.h>
#include  <sys/types.h>
#include  <signal.h>
#include  <sys/ipc.h>
#include  <sys/shm.h>
void  SIGINT_handler(int);
void  SIGQUIT_handler(int);
int   ID;
value_t *Pt;
void main(void)
{
int   i;
value_t value = getvalue();
key_t Key;
if (signal(SIGINT, SIGINT_handler) == SIG_ERR) {
printf(“SIGINT install error\n”);
exit(1);
}
if (signal(SIGQUIT, SIGQUIT_handler) == SIG_ERR) {
printf(“SIGQUIT install error\n”);
exit(2);
}
Key   = ftok(“.”, ‘s’);
ID   = get(Key, sizeof(value_t), IPC_CREAT | 0666);
Pt  = (value_t *) shmat(ID, NULL, 0);
*Pt = value;
for (i = 0; ; i++) {
printf(“From process %d: %d\n”, value, i);
sleep(1);
}
}
void  SIGINT_handler(int sig)
{
signal(sig, SIG_IGN);
printf(“From SIGINT: just got a %d (SIGINT ^C) signal\n”, sig);
signal(sig, SIGINT_handler);
}
void  SIGQUIT_handler(int sig)
{
signal(sig, SIG_IGN);
printf(“From SIGQUIT: ” sig);
shmdt(Pt);
shmctl(ID, IPC_RMID, NULL);
exit(3);
}

SIGCONT:
इस signal का , किसी प्रोसेस को सेंड करने के लिए किया जाता है | जिसे की perform करना है

c++ langugae मे signal-handling library को use करने के लिए निन्म syntax को use किया जाता है :-
void (*signal(int sig, void (*func)(int)))(int);
इस function से किसी signal को handel किया जाता सकता अहि | ये किसी signal को handel करने के लिए way और signal के number को specify करता है | parameter function तीन अलग अलग way को use करता है जिससे किसी signal को handel किया जा सकता है |
Default handling (SIG_DFL): इस signal को handel करने के लिए defualt ACTION को use किया जाता है |
Ignore signal (SIG_IGN):इस signal को ignore किया जाता है और code का execution continue होता है अगर signal का क्जोई भी मतलब नहीं होता है |
Function handler: इसमें किसी एक सेपेसिफ्य function को design किया जाता है जिससे किसी function को handel किया जाता है |

The signal() Function का syntax निन्म है :-
void (*signal (int sig, void (*func)(int)))(int);
इस syntax मे दो argument होते है :-
पहले argument एक integer है जिसका use signal के number को define करने के लिए किया जाता है |
दूसरा argument एक pointer है जिसे किसी signal को handel करने के लिए किया जाता है |
किसी c++ प्रोग्राम मे signal को ह्जन्देल किया जाता है तब जिस भी जगह पर signal को register करवाना चाहता हो उस जगह पर signal को catch करना पड़ता है और signal को signal handler से associate करना पड़ता है |

#include <iostream>
#include <csignal>
using namespace std;
void signalHandler( int signumber ) {
cout << “Interrupt signal (” << signumber << “) received.\n”;
// cleanup and close up stuff here
// terminate program
exit(signumber);
}
int main () {
// register signal SIGINT and signal handler
signal(SIGINT, signalHandler);
while(1) {
cout << “Sleep Mode start ” << endl;
sleep(1);
}
return 0;
}
जब इस प्रोग्राम को execute किया जाता है तब निन्म आउटपुट मिलता है
Sleep Mode star
Sleep Mode star
Sleep Mode star
जब किसी प्रोग्रामर और यूजर से CLTRS + ECS press करने पर signal प्राप्त होता है |
Sleep Mode start
Sleep Mode star
Sleep Mode star

The raise() Function
इस अलावा raise() फ़ुन्स्तिओन का use किसी signal को generate करने के लिए किया जाता है | आईएस function मे एक integer को pass किया जता है जिसका syntax निन्म है :
int raise (signal sig);
यहा पर sig एक variable है जिससे signal number को define किया जाता है इससे किसी भी type के signal जैसे SIGINT, SIGABRT, SIGFPE, SIGILL, SIGSEGV, SIGTERM, SIGHUP को sent किया जा सकता है |
इसका उदहारण निन्म है :
#include <iostream>
#include <csignal>
using namespace std;
void signalHandler( int signumber ) {
cout << “Interrupt signal (” << signumber << “) received.\n”;
// cleanup and close up stuff here
// terminate program
exit(signumber);
}
int main () {
int i = 0;
// register signal SIGINT and signal handler
signal(SIGINT, signalHandler);
while(++i) {
cout << “Sleep Mode start” << endl;
if( i == 3 ) {
raise( SIGINT);
}
sleep(1);
}
return 0;
}
जब इस code को execute किया जाता है तब इसका code निन्म है :
Sleep Mode start
Sleep Mode start
Sleep Mode start
Interrupt signal (2) received.

Sbistudy

Recent Posts

द्वितीय कोटि के अवकल समीकरण तथा विशिष्ट फलन क्या हैं differential equations of second order and special functions in hindi

अध्याय - द्वितीय कोटि के अवकल समीकरण तथा विशिष्ट फलन (Differential Equations of Second Order…

14 hours ago

four potential in hindi 4-potential electrodynamics चतुर्विम विभव किसे कहते हैं

चतुर्विम विभव (Four-Potential) हम जानते हैं कि एक निर्देश तंत्र में विद्युत क्षेत्र इसके सापेक्ष…

3 days ago

Relativistic Electrodynamics in hindi आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा

आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा Relativistic Electrodynamics in hindi ? अध्याय : आपेक्षिकीय विद्युतगतिकी…

5 days ago

pair production in hindi formula definition युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए

युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए pair production in hindi formula…

1 week ago

THRESHOLD REACTION ENERGY in hindi देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा

देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा THRESHOLD REACTION ENERGY in hindi…

1 week ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now