What are Unix signals?

一个信号,是一个信息,可以发送到运行的过程。

Signals can be initiated by programs, users, or administrators.信号可启动程式,使用者或管理员。

For example, to the proper method of telling the Internet Daemon (inetd) to re-read its configuration file is to send it a SIGHUP signal.举例来说,以适当的方法告诉互联网守护进程 ( inetd的) ,以重看其配置文件,是发送一个sighup信号。

For example, if the current process ID (PID) of inetd is 4140, we would type:举例来说,如果当前的进程ID ( PID控制)的inetd的是4140年,我们会类型:

 kill -SIGHUP 4140 

Another common use of signals is to stop a running process.另一种普遍使用的信号是停止一个运行的过程。 To stop the inetd process completely, we would use this command:停止inetd的进程完全中,我们会用这个命令:

 kill 4140 

By default, the kill command sends the SIGTERM signal.默认情况下,杀死指挥移送sigterm信号。 If SIGTERM fails, we can escalate to using the SIGKILL signal to stop the process:如果sigterm失败的话,我们可以升级使用sigkill信号,以阻止过程:

 kill -9 4140 

Because SIGKILL cannot be handled, stopping a process with SIGKILL is generally considered a bad idea.因为sigkill不能处理,制止过程中与sigkill被普遍认为是一个坏主意。 Using SIGKILL prevents a process from cleaning up after itself and exiting gracefully.用sigkill阻止一个进程,从清理后,本身并退出缓慢下降。

Handling Signals信号处理

Each Unix signal has a default set of effects on a Unix program.每个Unix信号具有默认设置的效果上的Unix程序。 Programmers can code their applications to respond in customized ways to most signals.程序员可以码及其应用响应定制的方式,以最信号。 These custom pieces of code are called signal handlers .这些习俗件代码是所谓的信号处理

Two signals are unable to be redefined by a signal handler.两路信号无法重新定义,由一个信号处理器。 SIGKILL always stops a process and SIGSTOP always moves a process from the foreground to the background. sigkill总是站有一个过程, sigstop总是一个过程,从前台到后台。 These two signals cannot be "caught" by a signal handler.这两个信号不能被"捕获"的一个信号处理器。

FreeBSD Signals

Signal NameSignal NumberSignal Description
SIGHUP1Terminal line hangup
SIGINT2Interrupt program
SIGQUIT3Quit program
SIGILL4Illegal instruction
SIGTRAP5Trace trap
SIGABRT6Abort
SIGEMT7Emulate instruction executed
SIGFPE8Floating-point exception
SIGKILL9Kill program
SIGBUS10Bus error
SIGSEGV11Segmentation violation
SIGSYS12Bad argument to system call
SIGPIPE13Write on a pipe with no one to read it
SIGALRM14Real-time timer expired
SIGTERM15Software termination signal
SIGURG16Urgent condition on I/O channel
SIGSTOP17Stop signal not from terminal
SIGTSTP18Stop signal from terminal
SIGCONT19A stopped process is being continued
SIGCHLD20Notification to parent on child stop or exit
SIGTTIN21Read on terminal by background process
SIGTTOU22Write to terminal by background process
SIGIO23I/O possible on a descriptor
SIGXCPU24CPU time limit exceeded
SIGXFSZ25File-size limit exceeded
SIGVTALRM26Virtual timer expired
SIGPROF27Profiling timer expired
SIGWINCH28Window size changed
SIGINFO29Information request
SIGUSR130User-defined signal 1
SIGUSR231User-defined signal 2
SIGTHR32Thread interrupt

Solaris Signals

Signal NameSignal NumberSignal Description
SIGHUP1Hangs up
SIGINT2Interrupts
SIGQUIT3Quits
SIGILL4Illegal instruction
SIGTRAP5Trace trap
SIGABRT6Used by abort
SIGEMT7EMT instruction
SIGFPE8Floating-point exception
SIGKILL9Kill (cannot be caught or ignored)
SIGBUS10Bus error
SIGSEGV11Segmentation violation
SIGSYS12Bad argument to system call
SIGPIPE13Writes on a pipe with no one to read it
SIGALRM14Alarm clock
SIGTERM15Software termination
SIGUSR116User-defined signal 1
SIGUSR217User-defined signal 2
SIGCHLD18Child status change alias (POSIX)
SIGPWR19Power-fail restart
SIGWINCH20Window size change
SIGURG21Urgent socket condition
SIGPOLL /SIGIO22Pollable event occurred or Socket I/O possible
SIGSTOP23Stop (cannot be caught or ignored)
SIGTSTP24User stop requested from TTY
SIGCONT25Stopped process has been continued
SIGTTIN26Background TTY read attempted
SIGTTOU27Background TTY write attempted
SIGVTALRM28Virtual timer expired
SIGPROF29Profiling timer expired
SIGXCPU30Exceeded CPU limit
SIGXFSZ31Exceeded file size limit
SIGWAITING32Process' LWPs are blocked
SIGLWP33Special signal used by thread library
SIGFREEZE34Special signal used by CPR
SIGTHAW35Special signal used by CPR
SIGCANCEL36Thread cancellation signal used by libthread
SIGLOST37Resource lost
SIGRTMIN38Highest priority real-time signal
SIGRTMAX45Lowest priority real-time signal


<script type="text/javascript"></script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值