raise.c

来自「用于嵌入式Linux系统的标准C的库函数」· C语言 代码 · 共 81 行

C
81
字号
/* Embedded systems may want the simulated signals if no other form exists,   but UNIX versions will want to use the host facilities.   Define SIMULATED_SIGNALS when you want to use the simulated versions.*//*FUNCTION<<raise>>---send a signalINDEX	raiseINDEX	_raise_rANSI_SYNOPSIS	#include <signal.h>	int raise(int <[sig]>);	int _raise_r(void *<[reent]>, int <[sig]>);TRAD_SYNOPSIS	#include <signal.h>	int raise(<[sig]>)	int <[sig]>;	int _raise_r(<[reent]>, <[sig]>)	char *<[reent]>;	int <[sig]>;DESCRIPTIONSend the signal <[sig]> (one of the macros from `<<sys/signal.h>>').This interrupts your program's normal flow of execution, and allows a signalhandler (if you've defined one, using <<signal>>) to take control.The alternate function <<_raise_r>> is a reentrant version.  The extraargument <[reent]> is a pointer to a reentrancy structure.RETURNSThe result is <<0>> if <[sig]> was successfully raised, <<1>>otherwise.  However, the return value (since it depends on the normalflow of execution) may not be visible, unless the signal handler for<[sig]> terminates with a <<return>> or unless <<SIG_IGN>> is ineffect for this signal.PORTABILITYANSI C requires <<raise>>, but allows the full set of signal numbersto vary from one implementation to another.Required OS subroutines: <<getpid>>, <<kill>>.*/#ifndef SIGNAL_PROVIDEDint _dummy_raise;#else#include <reent.h>#include <signal.h>#ifndef _REENT_ONLYint_DEFUN (raise, (sig),	int sig){  return _raise_r (_REENT, sig);}#endifint_DEFUN (_raise_r, (reent, sig),	struct _reent *reent _AND	int sig){  return _kill_r (reent, _getpid_r (reent), sig);}#endif /* SIGNAL_PROVIDED */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?