Lecture 01 Flashcards
What is POSIX?
A standard that attempts to define a common API across operating systems.
Which of the following OSes is not POSIX compliant?
Linux
Windows
MacOS
Windows.
Of course it’s fucking Windows.
What unix command is used to access the manual page for a given tool or library?
man
What is the function prototype for the function ‘open’?
int open(const char* pathname, int flags);
What different values can be passed as flags to the open() function?
O_RDONLY O_WRONLY O_RDWR O_TRUNC O_CREAT
What is the function prototype for read()?
ssize_t(int fd, void *buf, size_t count);
Why does read() return a ssize_t and not a size_t?
What’s the difference?
A ssize_t is a signed size_t.
read uses this so it can return -1 in the event of an error.
What function can be used to create a new file?
creat
What is the function prototype for creat?
int creat(const char* pathname, mode_t mode);
What stream number is stdin?
0
What stream number is stdout?
1
What stream number is stderr?
2
What is the function prototype for lseek?
off_t lseek(int fildes, off_t offset, int whence);
What does lseek do when whence is equal to ‘SEEK_SET’?
Sets the position to offset bytes from the start of the file.
What does lseek do when whence is equal to ‘SEEK_CUR’?
Sets the position to the current position plus offset bytes.