#include <signal.h>
struct sigaction {
void (*sa_handler)(int);
void (*sa_sigaction)(int, siginfo_t* , void* );
sigset_t sa_mask;
int sa_flags;
void (*sa_restorer)(void);
};
int sigaction(int signum, const struct sigaction* act,
struct sigaction* oloact);
#include <sys/types.h>
#include <sys/wait.h>
pid_t wait(int* status);
pid_t waitpid(pid_t pid, int* status, int options);
int waitid(idtype_t idtype, id_t id, siginfo_t* infop, int options);
/*
signal
EINTR
SIGCHLD
SIGPIPE
*/
/*
data format
1. transfer as string.
2. XDR
*/
/*
blocking I/O
nonblocking I/O
I/O multiplexing (select and poll)
signal driven I/O (SIGIO)
asynchronous I/O (the POSIX aio_functions)
*/
#include <sys/select.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/unistd.h>
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* microseconds */
};
struct timespec {
long tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
int select(int nfds, fd_set* readfds, fd_set* writefds,
fd_set* exceptfds, struct timeval* timeout);
void FD_CLR(int fd, fd_set* set);
int FD_ISSET(int fd, fd_set* set);
void FD_SET(int fd, fd_set* set);
void FD_ZERO(fd_set* set);
int pselect(int nfds, fd_set* readfds, fd_set* writefds,
const sigset_t* sigmask);
#include <sys/socket.h>
int shutdown(int sockfd, int how); /* how: SHUT_RD, SHUT_WR, SHUT_RDWR */
#include <poll.h>
struct pollfd {
int fd; /* file descriptor */
short events; /* requested events */
short revents; /* returned events */
};
int poll(struct pollfd* fds, nfds_t nfds, int timeout);
#define _GNU_SOURCE
#include <poll.h>
int ppoll(struct pollfd* fds, nfds_t nfds,
const struct timespec* timeout_ts, const sigset_t* sigmask);
The bits that may be set/returned inevents and revents are defined in <poll.h>:
POLLIN /* There is data to read. */
POLLPRI /* There is urgen data to read (e.g., out-of-band data on
TCP socket; pseudoterminal master in packet mode has seen
state change in slave). */
POOLOUT /* Writing now will not block. */
POLLRDHUP /* (since Linux 2.6.17) Stream socket peer closed connection, or
shut down writing half of connection. The _GNU_SOURCE feature
test macro must be define (before including any header files)
in order to obtain this definition. */
POLLERR /* Error condition (output only). */
POLLHUP /* Hang up (output only). */
POLLNVAL /* Invalid request: fd not open (output only). */
When compiling with _XOPEN_SOURCE define, one also has the following,
which convey no further information beyond the bits listed above:
POLLRDNORM /* Equivalent to POLLIN. */
POLLRDBAND /* Priority band data can be read (generally unused on Linux). */
POLLWRNORM /* Equivalent to POLLOUT. */
POLLWRBAND /* Priority data may be written. */
#include <stdio.h>
int fflush(FILE* stream);
#include <string.h>
char* strcat(char* dest, const char* src);