gtpc2m6mC/C++ Language Support User's Guide

sigaction-Examine and Change Signal Action

This function allows the calling process to examine or change the action associated with a signal.

Note:
The sigaction function is similar to the signal function.

Format

#include <signal.h>
int sigaction(          int            sig,
              const  struct sigaction *act,
                     struct sigaction *oact);

sig
One of the signals defined in the signal.h header file that corresponds to a signal to be examined or changed. See Table 13 for a list of supported signals.

act
One of the following:

oact
One of the following:

Normal Return

If successful, the sigaction function returns a value of 0.

Error Return

If unsuccessful, the sigaction function returns a value of -1 and sets errno to following:

EINVAL
One of the following is true:

Programming Considerations

Examples

The following example establishes a signal handler by using the sigaction function.

#include <sysapi.h>
#include <signal.h>

·
·
·
{ void ChldHndlr(int, siginfo_t *, void *); struct tpf_fork_input create_parameters; struct sigaction act, oact; pid_t child_pid; /* initialize the new signal action */ act.sa_handler = ChldHndlr; sigempty set(&act.sa_mask); act.sa_flags = 0; /* install SIG_CHLD signal handler */ sigaction(SIG_CHLD, &act, &oact); /* processing loop */
·
·
·
/* set up create_parameters */ create_parameters.program = "/bin/usr/usr1/app1.exe"
·
·
·
child_pid = tpf_fork(&create_parameters);
·
·
·
/* end of processing loop */ return; } void ChldHndlr(int signo, siginfo_t *info, void *context) { int chld_state; { /* If someone used kill() to send SIGCHLD, ignore it */ if (info.si_si_code != SI_USER) { exited_pid = wait( &chld_state ); /* query return status */
·
·
·
} return; }

Related Information