Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.sao.ru/hq/sts/linux/book/c_marshall/subsubsection2_18_4_3_1.html
Дата изменения: Unknown
Дата индексирования: Sat Sep 11 20:52:09 2010
Кодировка:

Поисковые слова: m 15
Sending Signals - <tt>kill()</tt>



Next: Receiving signals - signal() Up: Interrupts and Signals Previous: Interrupts and Signals

Sending Signals - kill()

int kill(int pid, int signal) - send a signal to a process, pid. If pid is greater than zero, the signal is sent to the process whose process ID is equal to pid. If pid is 0, the signal is sent to all processes, except system processes.

kill() returns 0 for a successful call, -1 otherwise and sets errno accordingly.

There is also a UNIX command called kill - see man pages.

NOTE: that unless caught or ignored, the kill signal terminates the process. Therefore protection is built into the system.

Only processes with certain access privileges can be killed off.

Basic rule: only processes that have the same user can send/receive messages.

The SIGKILL signal cannot be caught or ignored and will always terminate a process.

For examplekill(getpid(),SIGINT); would send the interrupt signal to the id of the calling process.

This would have a similar effect to exit() command. Also ctrl-c typed from the command sends a SIGINT to the process currently being.

unsigned int alarm(unsigned int seconds) - sends the signal SIGALRM to the invoking process after seconds seconds.


Dave.Marshall@cm.cf.ac.uk
Wed Sep 14 10:06:31 BST 1994