Syntax of system and library calls


fork(), pipe(), dup(), execlp(), wait()

int fork()

int pipe(fd)
int fd[2];

int dup2(fd1, fd2)

int execlp(file, arg0 [ , arg1,...  , argn ] (char *)0)
char *file, *arg0, *arg1, ..., *argn;

int wait(statusp)
int *statusp;

setjmp()/longjmp()

#include < setjmp.h >

int setjmp(env)
jmp_buf env;

void longjmp(env, val)
jmp_buf env;
int val;

malloc()/free()

char *malloc(size)
int size;

int free(ptr)
char *ptr;

select() and friends

#include < sys/types.h >
#include < sys/time.h >

int select (width, readfds, writefds, exceptfds, timeout)
int width;
fd_set *readfds, *writefds, *exceptfds;
struct timeval *timeout;

FD_SET (fd, &fdset)
FD_CLR (fd, &fdset)
FD_ISSET (fd, &fdset)
FD_ZERO (&fdset)
int fd;
fd_set fdset;