[an error occurred while processing this directive]

HP OpenVMS Systems

C Programming Language
Content starts here HP C

HP C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index


sigrelse (ALPHA, I64)

Removes the specified signal from the calling process's signal mask.

Format

#include <signal.h>

int sigrelse (int signal);


Argument

signal

The specified signal. The signal argument can be assigned any of the signals defined in the <signal.h> header file, except SIGKILL and SIGSTOP.

Description

The sighold , sigrelse , and sigignore functions provide simplified signal management:
  • The sighold function adds signal to the calling process's signal mask.
  • The sigrelse function removes signal from the calling process's signal mask.
  • The sigignore function sets the disposition of signal to SIG_IGN.

The sighold function, in conjunction with sigrelse and sigpause , can be used to establish critical regions of code that require the delivery of a signal to be temporarily deferred.

Upon success, the sigrelse function returns a value of 0. Otherwise, a value of - 1 is returned, and errno is set to indicate the error.

Note

These interfaces are provided for compatibility only. New programs should use sigaction and sigprocmask to control the disposition of signals.

Return Values

0 Indicates success.
- 1 Indicates an error; errno is set to the following value:
  • EINVAL -- The value of the signal argument is either an invalid signal number or SIGKILL.

sigsetjmp

Sets a jump point for a nonlocal goto.

Format

#include <setjmp.h>

init sigsetjmp (sigjmp_buf env, int savemask);


Arguments

env

An address for a sigjmp_buf structure.

savemask

An integer value that specifies whether you need to save the current signal mask.

Description

The sigsetjmp function saves its calling environment in its env argument for later use by the siglongjmp function.

If the value of savemask is not 0 (zero), sigsetjmp also saves the process's current signal mask as part of the calling environment.

See also siglongjmp .


Restrictions

You cannot invoke the longjmp function from an OpenVMS condition handler. However, you may invoke longjmp from a signal handler that has been established for any signal supported by the HP C RTL, subject to the following nesting restrictions:
  • The longjmp function will not work if you invoke it from nested signal handlers. The result of the longjmp function, when invoked from a signal handler that has been entered as a result of an exception generated in another signal handler, is undefined.
  • Do not invoke the sigsetjmp function from a signal handler unless the associated longjmp is to be issued before the handling of that signal is completed.
  • Do not invoke the longjmp function from within an exit handler (established with atexit or SYS$DCLEXH). Exit handlers are invoked after image tear-down, so the destination address of the longjmp no longer exists.
  • Invoking longjmp from within a signal handler to return to the main thread of execution might leave your program in an inconsistent state. Possible side effects include the inability to perform I/O or to receive any more UNIX signals. Use siglongjmp instead.

Return Values

0 Indicates success.
nonzero The return is a call to the siglongjmp function.

sigsetmask

Establishes those signals that are blocked from delivery.

Format

#include <signal.h>

int sigsetmask (int mask);


Argument

mask

The signals to be blocked.

Description

See the sigblock function for information about the mask argument.

Return Value

x The previous set of masked signals.

sigstack (VAX ONLY)

Defines an alternate stack on which to process signals. This allows the processing of signals in a separate environment from that of the current process. This function is nonreentrant.

Format

#include <signal.h>

int sigstack (struct sigstack *ss, struct sigstack *oss);


Arguments

ss

If ss is not NULL, it specifies the address of a structure that holds a pointer to a designated section of memory to be used as a signal stack on which to deliver signals.

oss

If oss is not NULL, it specifies the address of a structure in which the old value of the stack address is returned.

Description

The sigstack structure is defined in the <signal.h> standard header file:


struct sigstack 
   { 
      char     *ss_sp; 
      int      ss_onstack; 
   }; 

If the sigvec function specifies that the signal handler is to execute on the signal stack, the system checks to see if the process is currently executing on that stack. If the process is not executing on the signal stack, the system arranges a switch to the signal stack for the duration of the signal handler's execution. If the oss argument is not NULL, the current state of the signal stack is returned.

Signal stacks must be allocated an adequate amount of storage; they do not expand like the run-time stack. For example, if your signal handler calls printf or any similarly complex HP C RTL routine, at least 12,000 bytes of storage should be allocated for the signal stack. If the stack overflows, an error occurs.

ss_sp must point to at least four bytes before the end of the allocated memory area (see the example). This is architecture-dependent and possibly not portable to other machine architectures or operating systems.


Return Values

0 Indicates success.
- 1 Indicates failure.

Example


#define ss_size 15000 
static char mystack[ss_size]; 
struct sigstack ss = {&mystack + sizeof(mystack) - sizeof(void *), 1}; 

sigsuspend

Atomically changes the set of blocked signals and waits for a signal.

Format

#include <signal.h>

int sigsuspend (const sigset_t *signal_mask);


Argument

signal_mask

A pointer to a set of signals.

Description

The sigsuspend function replaces the signal mask of the process with the set of signals pointed to by the signal_mask argument. Then it suspends execution of the process until delivery of a signal whose action is either to execute a signal catching function or to terminate the process. You cannot block the SIGKILL or SIGSTOP signals with the sigsuspend function. If a program attempts to block either of these signals, sigsuspend gives no indication of the error.

If delivery of a signal causes the process to terminate, sigsuspend does not return. If delivery of a signal causes a signal catching function to execute, sigsuspend returns after the signal catching function returns, with the signal mask restored to the set that existed prior to the call to sigsuspend .

The sigsuspend function sets the signal mask and waits for an unblocked signal as one atomic operation. This means that signals cannot occur between the operations of setting the mask and waiting for a signal. If a program invokes sigprocmask SIG_SETMASK and sigsuspend separately, a signal that occurs between these functions is often not noticed by sigsuspend .

In normal usage, a signal is blocked by using the sigprocmask function at the beginning of a critical section. The process then determines whether there is work for it to do. If there is no work, the process waits for work by calling sigsuspend with the mask previously returned by sigprocmask .

If a signal is caught by the calling process and control is returned from the signal handler, the calling process resumes execution after sigsuspend , which always returns a value of - 1 and sets errno to EINTR.

See also sigpause and sigprocmask .


sigtimedwait (ALPHA, I64)

Suspends a calling thread and waits for queued signals to arrive.

Format

#include <signal.h>

int sigtimedwait (const sigset_t set, siginfo_t *info, const struct timespec *timeout);


Arguments

set

The set of signals to wait for.

info

Pointer to a siginfo structure that is receiving data describing the signal, including any application-defined data specified when the signal was posted.

timeout

A timeout for the wait. If timeout is NULL, the argument is ignored.

Description

The sigtimedwait function behaves the same as the sigwaitinfo function except that if none of the signals specified by set are pending, sigtimedwait waits for the time interval specified in the timespec structure referenced by timeout. If the timespec structure pointed to by timeout is zero-valued and if none of the signals specified by set are pending, then sigtimedwait returns immediately with an error.

See also sigwait and sigwaitinfo .

See Section 4.2 for more information on signal handling.


Return Values

x Upon successful completion, the signal number selected is returned.
- 1 Indicates that an error occurred; errno is set to one of the following values:
  • EINVAL -- The timeout argument specified a tv_nsec value less than 0 or greater than or equal to 1 billion.
  • EINTR -- The wait was interrupted by an unblocked, caught signal.
  • EAGAIN -- No signal specified by set was generated within the specified timeout period.

sigvec

Permanently assigns a handler for a specific signal.

Format

#include <signal.h>

int sigvec (int sigint, struct sigvec *sv, struct sigvec *osv);


Arguments

sigint

The signal identifier.

sv

Pointer to a sigvec structure (see the Description section).

osv

If osv is not NULL, the previous handling information for the signal is returned.

Description

If sv is not NULL, it specifies the address of a structure containing a pointer to a handler routine and mask to be used when delivering the specified signal, and a flag indicating whether the signal is to be processed on an alternative stack. If sv-->onstack has a value of 1, the system delivers the signal to the process on a signal stack specified with sigstack .

The sigvec function establishes a handler that remains established until explicitly removed or until the image terminates.

The sigvec structure is defined in the <signal.h> header file:


struct sigvec 
   { 
      int   (*handler)(); 
      int   mask; 
      int   onstack; 
   }; 
 

See Section 4.2 for more information on signal handling.


Return Values

0 Indicates that the call succeeded.
- 1 Indicates that an error occurred.

sigwait (ALPHA, I64)

Suspends a calling thread and waits for queued signals to arrive.

Format

#include <signal.h>

int sigwait (const sigset_t set, int *sig);


Arguments

set

The set of signals to wait for.

sig

Returns the signal number of the selected signal.

Description

The sigwait function suspends the calling thread until at least one of the signals in the set argument is in the caller's set of pending signals. When this happens, one of those signals is automatically selected and removed from the set of pending signals. The signal number identifying that signal is then returned in the location referenced by sig.

The effect is unspecified if any signals in the set argument are not blocked when the sigwait function is called.

The set argument is created using the set manipulation functions sigemptyset , sigfillset , sigaddset , and sigdelset .

If, while the sigwait function is waiting, a signal occurs that is eligible for delivery (that is, not blocked by the signal mask), that signal is handled asynchronously and the wait is interrupted.

See also sigtimedwait and sigwaitinfo .

See Section 4.2 for more information on signal handling.


Return Values

0 Upon successful completion, sigwait stores the signal number of the received signal at the location referenced by sig and returns 0.
nonzero Indicates that an error occurred; errno is set to the following value:
  • EINVAL -- The set argument contains an invalid or unsupported signal number.

sigwaitinfo (ALPHA, I64)

Suspends a calling thread and waits for queued signals to arrive.

Format

#include <signal.h>

int sigwaitinfo (const sigset_t set, siginfo_t *info);


Arguments

set

The set of signals to wait for.

info

Pointer to a siginfo structure that is receiving data describing the signal, including any application-defined data specified when the signal was posted.

Description

The sigwaitinfo function behaves the same as the sigwait function if the info argument is NULL.

If the info argument is non-NULL, the sigwaitinfo function behaves the same as sigwait , except that the selected signal number is stored in the si_signo member of the siginfo structure, and the cause of the signal is stored in the si_code member. If any value is queued to the selected signal, the first such queued value is dequeued and the value is stored in the si_value member of info. The system resource used to queue the signal is released and made available to queue other signals. If no value is queued, the content of the si_value member is undefined. If no further signals are queued for the selected signal, the pending indication for that signal is reset.

See also sigtimedwait and sigwait .

See Section 4.2 for more information on signal handling.


Return Values

x Upon successful completion, the signal number selected is returned.
- 1 Indicates that an error occurred; errno is set to one of the following values:
  • EINVAL -- The set argument contains an invalid or unsupported signal number.
  • EINTR -- The wait was interrupted by an unblocked, caught signal.

sin

Returns the sine of its radian argument.

Format

#include <math.h>

double sin (double x);

float sinf (float x); (ALPHA, I64)

long double sinl (long double x); (ALPHA, I64)

double sind (double x); (ALPHA, I64)

float sindf (float x); (ALPHA, I64)

long double sindl (long double x); (ALPHA, I64)


Argument

x

A radian expressed as a floating-point number.

Description

The sin functions compute the sine of x measured in radians.

The sind functions compute the sine of x measured in degrees.


Return Values

x The sine of the argument.
NaN x = ±Infinity or NaN; errno is set to EDOM.
0 Undeflow occurred; errno is set to ERANGE.

sinh

Returns the hyperbolic sine of its argument.

Format

#include <math.h>

double sinh (double x);

float sinhf (float x); (ALPHA, I64)

long double sinhl (long double x); (ALPHA, I64)


Argument

x

A real number.

Return Values

n The hyperbolic sine of the argument.
HUGE_VAL Overflow occurred; errno is set to ERANGE.
0 Underflow occurred; errno is set to ERANGE.
NaN x is NaN; errno is set to EDOM.

sleep

Suspends the execution of the current process for at least the number of seconds indicated by its argument.

Format

#include <unistd.h>

unsigned int sleep (unsigned seconds); (_DECC_V4_SOURCE)

int sleep (unsigned seconds); (NOT _DECC_V4_SOURCE)


Argument

seconds

The number of seconds.

Description

The sleep function sleeps for the specified number of seconds, or until a signal is received, or until the process executes a call to SYS$WAKE.

If a SIGALRM signal is generated, but blocked or ignored, the sleep function returns. For all other signals, a blocked or ignored signal does not cause sleep to return.


Return Values

x The number of seconds that the process awoke early.
0 If the process slept the full number of seconds specified by seconds.


Previous Next Contents Index