Midterm Exam Reference Page
You may detach this page and keep; nothing written on it will be marked.
fork/exec/pid (unistd.h)
pid_t fork(void);
int execl(const char *pathname, const char *arg, ... /*, (char *) NULL */);
int execlp(const char *file, const char *arg, ... /*, (char *) NULL */);
int execle(const char *pathname, const char *arg, ... /*, (char *) NULL, char *const envp[] */);
int execv(const char *pathname, char *const argv[]);
int execvp(const char *file, char *const argv[]);
int execvpe(const char *file, char *const argv[], char *const envp[]);
pid_t getpid(void);
pid_t getppid(void);
int brk(void *addr);
void *sbrk(intptr_t increment);
Wait (sys/wait.h)
pid_t wait(int *stat_loc);
pid_t waitpid(pid_t pid, int *wstatus, int options);
WIFEXITED(wstatus)
WEXITSTATUS(wstatus)
WIFSIGNALED(wstatus)
WTERMSIG(wstatus)
WCOREDUMP(wstatus)
WIFSTOPPED(wstatus)
WSTOPSIG(wstatus)
WIFCONTINUED(wstatus)
Signals (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 *oldact);
// Signals: SIGINT, SIGKILL, SIGSEGV, SIGTERM
int kill(pid_t pid, int sig);
int raise(int sig);
Unbuffered I/O (fcntl.h, unistd.h)
// fd's: STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO
int open(const char *pathname, int flags);
// flags: O_RDONLY, O_WRONLY, O_RDWR,
// O_APPEND, O_CREAT, O_NONBLOCK
int open(const char *pathname, int flags, mode_t mode);
// mode creating: S_IRWXU, S_IRUSR, S_IWUSR, S_IRWXG
ssize_t write(int fd, const void *buf, size_t count);
ssize_t read(int fd, void *buf, size_t count);
int close(int fd);
off_t lseek(int fd, off_t offset, int whence);
// whence = SEEK_SET, SEEK_CUR, SEEK_END
int fcntl(int fd, int op, ... /* arg */ );
C Standard Library I/O (stdio.h)
// FILE`s: stdin, stdout, stderr
FILE *fopen(const char *pathname, const char *mode);
int fclose(FILE *stream);
int fprintf(FILE *stream, const char *format, ...);
int fscanf(FILE *stream, const char *format, ...);
int fputc(int c, FILE *stream);
int fputs(const char *s, FILE *stream);
int fgetc(FILE *stream);
char *fgets(char s, int size, FILE *stream);
FILE *fdopen(int fd, const char *mode);
int fileno(FILE *stream);
int fflush(FILE *stream);
General Functions
// (string.h)
void *memset(void *s, int c, size_t n);
char *strncpy(char *dst, const char *src, size_t dsize);
char *strtok_r(char *str, const char *delim, char **saveptr);
size_t strnlen(const char s[.maxlen], size_t maxlen);
// (ctype.h)
int toupper(int c);
int tolower(int c);
int isalpha(int c);
int isdigit(int c);
int isspace(int c);
// (stdlib.h)
int rand(void);
// (stdio.h)
void perror(const char *s);
ssize_t getline(char **lineptr, size_t *n, FILE *stream);
int snprintf(char *str, size_t size, const char *format, ...);
// (unistd.h)
unsigned int sleep(unsigned int seconds);
void *malloc(size_t size);
void free(void *_Nullable ptr);