CPP Interoperability & System Programming Flashcards
6 cards from real CPP practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 CPP Interoperability & System Programming flashcards as text
Which POSIX function creates a new child process?
Answer: fork()
fork() creates a new process by duplicating the calling process; the child receives a copy of the parent's address space.
What does the mmap() system call do?
Answer: Maps a file or anonymous region into the process's virtual address space
mmap() maps a file or anonymous memory region into the virtual address space of the process, enabling efficient file I/O and shared memory.
What does write() return when it encounters an error?
Answer: -1
Like most POSIX I/O system calls, write() returns -1 on error and sets the global errno to indicate the specific failure.
Which signal is delivered to a process when it accesses an invalid memory address?
Answer: SIGSEGV
SIGSEGV (segmentation violation) is sent by the kernel when a process attempts to access memory outside its allowed address space.
What does the POSIX pipe() function create?
Answer: A unidirectional IPC channel with a read end and write end
pipe() creates a pair of file descriptors forming a unidirectional channel: data written to one end can be read from the other.
Which modern POSIX function should be used for hostname-to-address resolution instead of the deprecated gethostbyname()?
Answer: getaddrinfo()
getaddrinfo() is the thread-safe, IPv6-capable replacement for the deprecated gethostbyname() for resolving hostnames to addresses.