Previous | Table of Contents | Next

Page 855

shutdown

shutdown—Shuts down part of a full-duplex connection

SYPNOSIS

#include <sys/socket.h>
int shutdown(int s,int how);

DESCRIPTION

The shutdown call causes all or part of a full-duplex connection on the socket associated with s to be shut down. If how is 0, further receives will be disallowed. If how is 1, further sends will be disallowed. If how is 2, further sends and receives will be disallowed.

RETURN VALUE

On success, 0 is returned. On error, _1 is returned, and errno is set appropriately.

ERRORS

EBADF s is not a valid descriptor.
ENOTSOCK s is a file, not a socket.
ENOTCONN The specified socket is not connected.

HISTORY

The shutdown function call appeared in BSD 4.2.

SEE ALSO

connect(2), socket(2)

BSD Man Page, 24 July 1993

sigaction, sigprocmask, sigpending, sigsuspend

sigaction, sigprocmask, sigpending, sigsuspend—POSIX signal-handling functions.

SYPNOSIS

#include <signal.h>
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
int sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
int sigpending(sigset_t *set);
int sigsuspend(const sigset_t *mask);

DESCRIPTION

The sigaction system call is used to change the action taken by a process on receipt of a specific signal.

signum specifies the signal and can be any valid signal except SIGKILL and SIGSTOP.

If act is non_null, the new action for signal signum is installed from act. If oldact is non_null, the previous action is saved in oldact.

The sigaction structure is defined as

struct sigaction {
    void (*sa_handler)(int);
    sigset_t sa_mask;
    int sa_flags;

Page 856


    void (*sa_restorer)(void);
}

sa_handler specifies the action to be associated with signum and can be SIG_DFL for the default action, SIG_IGN to ignore this signal, or a pointer to a signal-handling function.

sa_mask gives a mask of signals that should be blocked during execution of the signal handler. In addition, the signal that triggered the handler will be blocked unless the SA_NODEFER or SA_NOMASK flag is used.

sa_flags specifies a set of flags that modify the behavior of the signal-handling process. It is formed by the bitwise OR of zero or more of the following:

SA_NOCLDSTOP If signum is SIGCHLD, do not receive notification when child processes stop (that is, when child processes receive one of SIGSTOP, SIGTSTP, SIGTTIN, or SIGTTOU).
SA_ONESHOT or SA_RESETHAND Restores the signal action to the default state once the signal handler has been called. (This is the default behavior of the signal(2) system call.)
SA_RESTART Provides behavior compatible with BSD signal semantics by making certain system calls restartable across signals.
SA_NOMASK or SA_NODEFER Does not prevent the signal from being received from within its own signal handler.

The sa_restorer element is obsolete and should not be used.

The sigprocmask call is used to change the list of currently blocked signals. The behavior of the call is dependent on the value of how, as follows:

SIG_BLOCK The set of blocked signals is the union of the current set and the set argument.
SIG_UNBLOCK The signals in set are removed from the current set of blocked signals. It is legal to attempt to unblock a signal that is not blocked.
SIG_SETMASK The set of blocked signals is set to the argument set.

If oldset is non_null, the previous value of the signal mask is stored in oldset.

The sigpending call allows the examination of pending signals (those that have been raised while blocked). The signal mask of pending signals is stored in set.

The sigsuspend call temporarily replaces the signal mask for the process with that given by mask and then suspends the process until a signal is received.

RETURN VALUES

sigaction, sigprocmask, sigpending, and sigsuspend return 0 on success and -1 on error.

ERRORS

EINVAL An invalid signal was specified. This will also be generated if an attempt is made to change the action for SIGKILL or SIGSTOP, which cannot be caught.
EFAULT act, oldact, set, or oldset points to memory that is not a valid part of the process address space.
EINTR System call was interrupted.

NOTES

It is not possible to block SIGKILL or SIGSTOP with the sigprocmask call. Attempts to do so will be silently ignored.

Setting SIGCHLD to SIG_IGN provides automatic reaping of child processes.

The POSIX spec only defines SA_NOCLDSTOP. Use of other sa flags is non_portable.

The SA_RESETHAND flag is compatible with the SVR4 flag of the same name.

Previous | Table of Contents | Next

1