by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :)by MathLes and ClintCode AYYILDIZ TEAM :) Computer Engineering Tips - Computer Engineering news and articles - Signals Computer Engineering Tips - Computer Engineering news and articles - Signals
  Home arrow Operating Systems arrow Fundamentals arrow Signals
Computer Engineering Tips - Computer Engineering news and articles | _DATE_FORMAT_LC
 
 
Main Menu
Home
News
Algorithms
Artificial Intelligence
Bioinformatics
Computer Graphics
Computer Networks
Computer Organization
Computer Security
Data Mining
Data Structures
Database Systems
Distributed Computing
Internet
Operating Systems
Parallel Computing
Programming Languages
Publications
Robotics
Software Engineering
Other Articles


Partners

All Partners

 
 
 
Signals _CMN_EMAIL
_USER_RATING: / 0
_VOTE_POOR_VOTE_BEST 

Signals are mechanisms for communicating with and manipulating the processes in Linux. Signals, being special messages sent to a process are asynchronous. Immediate processing of the signals without finishing the current execution is done once a process receives a signal. There are several dozen different signals, each with a different meaning. Each signal type is specified by its signal number, but in programs, you usually refer to a signal by its name. In Linux, these are generally defined in /usr/include/bits/signum.h

Signal Fundamentals

When a process receives signals it may do one of the several things, depending on the signals disposition. A default disposition determining what happens to the process if the program does not specify some other behavior is there for each signal. Ignoring of the signal or calling special signal-handler function is to be decided by a program for most signal types. If a signal handler is used, the currently executing program is paused, the signal handler is executed, and when the signal handler returns, the program resumes. The Linux system sends signals to processes in response to specific conditions. For instance, SIGBUS (bus error), SIGSEGV (segmentation violation), and SIGFPE (floating point exception) may be set to a process that attempts t perform an illegal operation. The default disposition for these signals is to terminate the process and produce a core file.

A SIGTERM or SIGKILL signal can be used for sending signals to other processes. Another common use is to send a command to a running program. Two “user-defined” signals are reserved for this purpose: SIGUSR1 and SIGUSR2. For waking up an idling program or for rereading its own configuration files, SIGHUP signal is used.

The sigaction function can be used to set a signal disposition. The first parameter is the signal number. The next two parameters are pointers to sigaction structures; the first of these contains the desired disposition for that signal number, while the second receives the previous disposition. The most important field in the first or second sigaction structure is sa_handler. It can take one of the three values:

  • SIG_DFL, default disposition for the signal is specified.
  • SIG_IGN, signal should be ignored.
  • A pointer to a signal-handler function. The function should take one parameter, the signal number, and return void.

Because signals are asynchronous, the main program may be in a very fragile state when a signal is processed and thus while a signal handler function executes. Therefore avoid performing any I/O operations or calling most library and system function from signal handlers.

Returning of the control to the main program after responding to the signal is to be done by the signal handler. In most cases, this consists simply of recording the fact that a signal occurred. Occurrence of the signal is checked continuously and main program reacts accordingly to it.

Interrupt for the signal handler can be provided through delivery of another signal.

While this may sound like a rare occurrence, if it does occur, it will be very difficult to diagnose and debug the problem.

Even assigning a value to a global variable can be dangerous because the assignment may actually be carried out in two machine instructions, and a second signal may occur between then, leaving the variable in a corrupted state. If you use a global variable to flag a signal from a signal-handler function, it should be of the special type sig_atomic_t. Linux guarantees that assignments to variables of this type are performed in a single instruction and therefore cannot be interrupted midway. In linux sig_atomic_t is an ordinary int. If the user wants to write a program that is portable to any standard Unix system, though, use sig_atomic_t for these global variables.

 
 Sponsored Links

_USER_RATING: / 0
_VOTE_POOR_VOTE_BEST 
_ITEM_PREVIOUS   _ITEM_NEXT
 
       
         
     
 
Advertisement
 
   

Copyright 2005 - 2006 Science Tips Team. All rights reserved.

Nanotechnology Development Blog