views:

1616

answers:

10

This comment confuses me: "kill -l generally lists all signals". I thought that a signal means a quantized amount of energy.

[Added] Please, clarify the (computational) signal in Unix and the physical signal. Are they totally different concepts?

[Added] Are there major differences between paradigms? Is the meaning the same in languages such as C, Python and Haskell? The signal seems to be a general term.

+2  A: 

A signal is "an event, message, or data structure transmitted between computational processes" (from Wikipedia).

Ben
+1  A: 

In this case signal means 'message'. So it's sending a message to a process which can tell the process to do various things.

Goog
+4  A: 

A signal is a message, either to the target process, or to the OS about the target process. It is part of the unix API (and is defined in various POSIX standards).

Read man kill, man signal, and man sigaction.

Other SO questions that might be helpful:

dmckee
+3  A: 

A signal is a message which can be sent to a running process.

For example, to tell the Internet Daemon (inetd) to re-read its configuration file, it should be sent a SIGHUP signal.

For example, if the current process ID (PID) of inetd is 1234, you would type: kill -SIGHUP 1234

Paul Lydon
+12  A: 

The manual refers to a very basic mechanism that allow processes or the operation system to notify other processes by sending a signal. The operation system can use it to notify programs about abortions of them (signal SIGABRT) or about a segmentation fault (often caused by accessing a null-pointer, SIGSEGV), to name two of them.

Some unix servers use signals so the administrator can use kill to send them a signal, causing them to re-read their configuration file, without requiring them to restart.

There are default actions taken for some signals and other signals are just ignored. For example on receive of a SIGSEGV, the program terminates, while receiving a SIGCHLD, meaning a child-process died, will by default result in nothing special.

There is a ANSI C standard function that installs a signal handler, which is a function that can execute some code when receiving a signal, called signal (read in man signal). In different unix's, that function behave different, so its usage is discouraged. Its manpage refers to the sigaction function (read man sigaction), which behaves consistent, and is also more powerful.

Johannes Schaub - litb
The signal does not seem to have anything to do with the physical meaning. Are the concept still the same, such as "sampling", "digital" and "noise"?
Masi
HL: no. You are using a fairly specialized domain meaning. Thie usage here is much more like the usage in ordinary life (e.g. a traffic signal).
dmckee
Signals are defined at operation-system level. It doesn't matter which language you are using since signal handling is properly implemented by the language.
goodrone
+3  A: 

Some from my notes :

Allows asynchronous communication

  • Between processes belonging to the same user
  • From the system to any process
  • From the system manager to any process
  • All associated information is in the signal itself
  • Many different signals

SIGINT

  • From the system to all processes associated to a terminal
  • Trigger: ^C pressed
  • Usual way to stop a running process

SIGFPE

  • From the kernel to a single process
  • Trigger: error in floating point operation

SIGKILL

  • To a single process
  • Stops the execution of the destination process

SIGALRM

  • From the kernel to a single process
  • Trigger: timer expiration

SIGTERM

  • To a single process
  • Recommends the process to terminate gracefully

SIGUSR1, SIGUSR2

  • From any process to any other
  • Without a predefined semantic
  • Freely usable by programmers

Sending a signal to another process

  • int kill(pid, signal_ID)

The programmer can decide what to do when a signal is received

  • Use the default behavior
  • Ignore it
  • Execute a user function

Detecting an interrupted write

if (write(fd, buff, SIZE)<0) {
  switch (errno) {
   case EINTR:
    warning(“Interrupted write\n”);
    break;
  }
}…
Can Erten
A: 

A unix signal is a kind of message that can be sent to and from unix processes. They can do things like tell a process to quit (SIGKILL) or that a process had an invalid memory reference (SIGSEGV) or that the process was killed by the user hitting control-c (SIGINT).

from a *nix command line type in:

man signal

that will should you all the signals available.

hacintosh
+9  A: 

A physical signal and a Unix signal are indeed different concepts. When a Unix signal is sent from one process to another, there is no specific corresponding physical signal. Unix signals are merely an abstraction so programmers can talk about processes communicating with one another.

Unix signals could have been called messages, events, notifications, or even a made-up term like "frobs". The designers just chose the name "signal", and it stuck.

Greg Hewgill
They could have been called "software interrupts", as well.
Roboprog
+7  A: 

I cannot believe that people are not comparing things such as hardware and software or stressing OS at some points.

Comparison between a signal and an interrupt:

The difference is that while interrupts are sent to the operating system by the hardware, signals are sent to the process by the operating system, or by other processes. Note that signals have nothing to do with software interrupts, which are still sent by the hardware (the CPU itself, in this case). (source)

Definitions

  1. process = a program in execution, according to the book below

Further reading

  1. compare the signal to Interrupts and Exceptions

  2. Tanenbaum's book Modern Operating Systems

HH
This is an excellent answer! I cannot vote him up, since I have no votes at the moment. Please, vote him up.
Masi
A: 

@Greg,Roboprog 'Traffic singnal', 'no hand signal' are also to be changed.

Siddique