Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
signal(2)		      System Calls Manual		     signal(2)

NAME
       signal, sigset, sighold,	sigrelse, sigignore, sigpause -	signal manage-
       ment

SYNOPSIS
DESCRIPTION
       The function chooses one	of three ways in which receipt of  the	signal
       number  sig  is to be subsequently handled. If the value	of func	is de-
       fault handling for that signal will occur.  If the value	of func	is the
       signal  will be ignored.	Otherwise, func	must point to a	function to be
       called when that	signal occurs. Such a function is called a signal han-
       dler.

       When  a	signal occurs, if func points to a function, first the equiva-
       lent of a:

       is executed or an implementation-dependent blocking of  the  signal  is
       performed.  (If	the value of sig is whether the	reset to occurs	is im-
       plementation-dependent.)	Next the equivalent of:

       is executed. The	func function may  terminate  by  executing  a	return
       statement or by calling or If executes a	return statement and the value
       of sig was or any other implementation-dependent	value corresponding to
       a  computational	exception, the behaviour is undefined.	Otherwise, the
       program will resume execution at	the point it was interrupted.

       If the signal occurs other than as the result of	calling	or the	behav-
       iour is undefined if the	signal handler calls any function in the stan-
       dard library other than one of the functions listed on the sigaction(2)
       page or refers to any object with static	storage	duration other than by
       assigning a value  to  a	 static	 storage  duration  variable  of  type
       volatile	sig_atomic_t.  Furthermore, if such a call fails, the value of
       is indeterminate.

       At program startup, the equivalent of:

       is executed for some signals, and the equivalent	of:

       is executed for all other signals (see

       The and functions provide simplified signal management.

       The function is used to modify signal dispositions.  The	 sig  argument
       specifies the signal, which may be any signal except and	The disp argu-
       ment specifies the signal's disposition,	which may be or	the address of
       a  signal handler. If is	used, and disp is the address of a signal han-
       dler, the system	will add sig to	the calling process' signal  mask  be-
       fore executing the signal handler; when the signal handler returns, the
       system will restore the calling process'	signal mask to its state prior
       the  delivery of	the signal. In addition, if is used, and disp is equal
       to sig will be added to the calling process' signal mask	and sig's dis-
       position	 will  remain  unchanged. If is	used, and disp is not equal to
       sig will	be removed from	the calling process' signal mask.

       The function adds sig to	the calling process' signal mask.

       The function removes sig	from the calling process' signal mask.

       The function sets the disposition of sig	to

       The sigpause() function removes sig from	the  calling  process'	signal
       mask and	suspends the calling process until a signal is received.

       If  the	action for the signal is set to	child processes	of the calling
       processes will not be transformed into zombie processes when they  ter-
       minate. If the calling process subsequently waits for its children, and
       the process has no unwaited for children	 that  were  transformed  into
       zombie  processes,  it  will block until	all of its children terminate,
       and and will fail and set to

RETURN VALUE
       If the request can be honoured, returns the value of for	the  most  re-
       cent  call to for the specified signal sig.  Otherwise, is returned and
       a positive value	is stored in

       Upon successful completion, returns if the signal had been blocked  and
       the  signal's  previous	disposition if it had not been blocked.	Other-
       wise, is	returned and is	set to indicate	the error.

       For all other functions,	upon successful	 completion,  0	 is  returned.
       Otherwise, -1 is	returned and is	set to indicate	the error.

ERRORS
       The function will fail if:

	      [EINVAL]	     The  sig argument is not a	valid signal number or
			     an	attempt	is made	to catch a signal that	cannot
			     be	 caught	 or ignore a signal that cannot	be ig-
			     nored.

       The function may	fail if:

	      [EINVAL]	     An	attempt	was made to set	the action  to	for  a
			     signal  that  cannot  be  caught  or  ignored (or
			     both).

       The and functions will fail if:

	      [EINVAL]	     The sig argument is an illegal signal number.

       The and functions will fail if:

	      [EINVAL]	     An	attempt	is made	to catch a signal that	cannot
			     be	 caught,  or to	ignore a signal	that cannot be
			     ignored.

APPLICATION USAGE
       The function provides a more comprehensive and reliable	mechanism  for
       controlling signals; new	applications should use	rather than

       The  function, in conjunction with or may be used to establish critical
       regions of code that require the	delivery of a signal to	be temporarily
       deferred.

       The function should be used in preference to for	broader	portability.

   Threads Considerations
       The signal disposition (such as catch/ignore/default) established by is
       shared by all threads in	the process.  Blocked signal masks  are	 main-
       tained by each thread.

       If  is used to set the signal disposition for sig to or to for a	signal
       whose default action is to ignore the  signal,  any  instances  of  sig
       pending	on  the	 process or any	of the threads will be discarded.  The
       signals are discarded regardless	of whether the signal  is  blocked  by
       any of the threads.

       For more	information regarding signals and threads, refer to signal(5).

SEE ALSO
       exec(2),	pause(2), sigaction(2),	waitid(2), <signal.h>.

CHANGE HISTORY
       First released in Issue 1.

       Derived from Issue 1 of the SVID.

Issue 4
       The  following  changes	are  incorporated for alignment	with the ISO C
       standard:

	      -		The function is	no longer marked as an extension.

	      -		The argument int is added to the definition of in  the
			SYNOPSIS section.

	      -		In  Issue 3, this interface cross-referred to This is-
			sue provides a complete	description of the function as
			defined	in ISO C standard.

       Another change is incorporated as follows:

	      -		The APPLICATION	USAGE section is added.

Issue 4, Version 2
       The following changes are incorporated for X/OPEN UNIX conformance:

	      -		The and	functions are added to the SYNOPSIS.

	      -		The  DESCRIPTION  is  updated to describe semantics of
			the above interfaces.

	      -		Additional text	is added to the	RETURN	VALUE  section
			to describe possible returns from the function specif-
			ically,	and all	of the above functions in general.

	      -		The ERRORS section is restructured to describe	possi-
			ble error returns from each of the above functions in-
			dividually.

	      -		The APPLICATION	USAGE section is updated  to  describe
			certain	programming considerations associated with the
			X/OPEN UNIX functions.

signal(2)		      System Calls Manual		     signal(2)

				  HP-UX	EXTENSIONS

SYNOPSIS
DESCRIPTION
       The system defines a set	of signals that	can be delivered to a process.
       The  set	of signals is defined in signal(5), along with the meaning and
       side effects of each signal.  An	alternate mechanism for	handling these
       signals	is  defined here.  The facilities described here should	not be
       used in conjunction with	the  other  facilities	described  under  sig-
       nal(2),	sigvector(2),  sigblock(2),  sigsetmask(2),  sigpause(3C), and
       sigspace(2).

       Acceptable values for sig are defined in

	      Execute the default action, which	varies depending on  the  sig-
	      nal.
			  The  default action for most signals is to terminate
			  the process (see signal(5)).

			  A pending signal is discarded	(whether or not	it  is
			  blocked)  if action is set to	but the	default	action
			  of the pending signal	is to ignore the signal	(as in
			  the case of

	      Ignore the signal.

			  When is called with action set to and	an instance of
			  the signal sig is pending,  the  pending  signal  is
			  discarded, whether or	not it is blocked.

			  and signals cannot be	ignored.

	      address	  Catch	the signal.

			  Upon	receipt	 of signal sig,	reset the value	of ac-
			  tion for the caught signal to	SIG_DFL	 (except  sig-
			  nals	marked	with "not reset	when caught"; see sig-
			  nal(5)), call	the signal-catching function to	 which
			  address  points,  and	resume executing the receiving
			  process at the point where it	was interrupted.

			  The signal-catching function is called with the fol-
			  lowing three parameters:

			       sig     The signal number.

			       code    A  word of information usually provided
				       by the hardware.

			       scp     A  pointer  to  the   machine-dependent
				       structure sigcontext defined in

			  The  pointer scp is valid only during	the context of
			  the signal-catching function.	 The structure pointer
			  scp is always	defined.

			  The  code word is always zero	for all	signals	except
			  and For code has the following values:

			       illegal instruction trap;
			       break instruction trap;
			       privileged operation trap;
			       privileged register trap.

			  For code has the following values:

			       overflow	trap;
			       conditional trap;
			       assist exception	trap;
			       assist emulation	trap.

			  As defined by	the IEEE POSIX	Standard,  HP-UX  does
			  not  raise  an exception on floating-point divide by
			  zero.	 The result of floating-point divide  by  zero
			  is infinity which can	be checked by isinf(3M).

			  The signals and cannot be caught.

       allows the calling process to choose one	of four	ways to	handle the re-
       ceipt of	a specific signal.  sig	specifies the signal and  func	speci-
       fies the	choice.

	      sig    can  be  any one of the signals described under signal(5)
		     except or

	      func   is	assigned one of	four values: or	 a  function  address.
		     The  actions  prescribed  by and are described under sig-
		     nal(5).  The action prescribed by	and  function  address
		     are described below:

			Hold signal. The signal	 sig is	held upon receipt. Any
						 pending signal	of this	signal
						 type  remains	held. Only one
						 signal	of each	type is	 held.
						 Note:	the signals and	cannot
						 be held.

			function address	 Catch signal.	func must be a
						 pointer  to  a	 function, the
						 signal-   catching   handler,
						 that  is  called  when	signal
						 sig occurs.   specifies  that
						 the  process calls this func-
						 tion upon receipt  of	signal
						 sig.	Any  pending signal of
						 this type is  released.  This
						 handler  address  is retained
						 across	 calls	to  the	 other
						 signal	 management  functions
						 listed	here. Upon receipt  of
						 signal	  sig,	the  receiving
						 process  executes  the	  sig-
						 nal-catching function pointed
						 to by func as described under
						 signal(5)  with the following
						 differences:

						 Before	  calling   the	  sig-
						 nal-catching	handler,   the
						 system	signal action  of  sig
						 is set	to During a normal re-
						 turn from the signal-catching
						 handler,  the	system	signal
						 action	is  restored  to  func
						 and  any  held	signal of this
						 type  is   released.	If   a
						 non-local  goto (longjmp(3C))
						 is taken, must	be  called  to
						 restore the system signal ac-
						 tion to func and release  any
						 held signal of	this type.

       holds the signal	sig.  restores the system signal action	of sig to that
       specified previously by and are used to establish critical  regions  of
       code.   is  analogous  to  raising  the priority	level and deferring or
       holding a signal	until the priority is lowered by

       sets the	action for signal sig to (see signal(5)).

       suspends	the calling process until it receives an unblocked signal.  If
       the  signal  sig	is held, it is released	before the process pauses.  is
       useful for testing variables that are changed  when  a  signal  occurs.
       For  example,  should  be used to block the signal first, then test the
       variables.  If they have	not changed, call to wait for the signal.

       These functions can be linked into a program by giving the -lV3	option
       to the command (see ld(1)).

ERRORS
       fails and the system signal action for sig is not changed if any	of the
       following occur:

	      [EFAULT]		       The func	argument points	to memory that
				       is  not a valid part of the process ad-
				       dress space. Reliable detection of this
				       error is	implementation-dependent.

       and  fail and the system	signal action for sig is not changed if	any of
       the following occur:

	      [EINVAL]		       An attempt is made to ignore, hold,  or
				       supply a	handler	for a signal that can-
				       not be ignored, held,  or  caught;  see
				       signal(5).

       returns when the	following occurs:

	      [EINTR]		       A signal	was caught.

EXAMPLES
       The  following  call to sets up a signal-catching function for the sig-
       nal:

WARNINGS
       should not be used in conjunction with the facilities  described	 under
       bsdproc(3C), sigaction(2), sigset(3C), or sigvector(2).

       does  not  detect an invalid value for action, and if it	does not equal
       or or point to a	valid function address,	subsequent receipt of the sig-
       nal sig causes undefined	results.

AUTHOR
       was developed by	HP, AT&T, and the University of	California, Berkeley.

SEE ALSO
       kill(1),	 init(1M), exit(2), kill(2), lseek(2), pause(2), sigaction(2),
       sigvector(2), wait(2), abort(3C), setjmp(3C), signal(5).

STANDARDS CONFORMANCE
								     signal(2)

NAME | SYNOPSIS | DESCRIPTION | RETURN VALUE | ERRORS | APPLICATION USAGE | SEE ALSO | CHANGE HISTORY | Issue 4 | Issue 4, Version 2 | SYNOPSIS | DESCRIPTION | ERRORS | EXAMPLES | WARNINGS | AUTHOR | SEE ALSO | STANDARDS CONFORMANCE

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=signal&sektion=2&manpath=HP-UX+11.22>

home | help