1/19
Flashcards covering systems programming concepts including process creation (fork), process replacement (exec), process synchronization (wait), and management of zombie and orphan processes.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What is the distinction between a program and a process?
A program is an executable file, whereas a process is an instance of a program being executed.
What is systems programming as defined in the transcript?
Taking advantage of system calls to do things beyond standard C programming, such as creating multiple processes or communicating between programs.
What is a Process ID (PID) and which C type represents it?
A PID is a unique identifier for a process, represented in C by the pid_t type.
Which process serves as the ancestor of every process on a Linux system?
The init process or systemd, which is process ID 1.
What are the three possible return values of the fork() system call?
It returns a non-zero value (the child's PID) to the parent, zero to the child, or −1 if an error occurred.
What does the error code EAGAIN indicate when returned by fork()?
A system-imposed limit on the number of processes or threads was encountered.
What is the relationship between parent and child memory spaces after a fork()?
The memory space is copied; they are separate processes and do not share memory in general.
What resources are shared between a parent and child process after a fork()?
Open files, including standard input, standard output, and standard error.
What is 'line buffering' in the context of the C standard library?
Buffering where output is sent to the standard output only when a new line is encountered, typically used when outputting to a terminal.
When does the C standard library use 'block buffering' instead of 'line buffering'?
When the standard output is directed to a file or a pipe rather than a terminal.
What utility can check or set the limit on the maximum number of user processes?
ulimit −u
What is the difference between the exit() library function and the \textunderscore exit() system call?
exit() flushes output streams and runs exit hooks (atexit), while \textunderscore exit() is the underlying system call that avoids these steps.
What is a zombie (defunct) process?
A process that has ended but remains in the process table because its parent has not yet reaped it to inquire about its exit status.
Why can one not 'kill' a zombie process?
Because the process has already ended and all its resources are claimed; it only exists as an entry in the process table until the parent calls wait.
What happens to a child process if its parent dies (an orphan process)?
It is inherited (adopted) by the original ancestor process (systemd, process ID 1).
What is the purpose of the wait() system call?
To block the parent until a child process becomes a zombie, allowing the parent to reap the child and obtain its exit status.
Which macro is used to check if a process terminated normally in C?
WIFEXITED(status)
Which macro extracts the actual exit code from the status returned by wait()?
WEXITSTATUS(status)
How does the WNOHANG option modify the behavior of waitpid()?
It causes the function to return immediately if no child has exited, rather than blocking.
What happens to the calling process during a successful exec() call?
The current program's memory is replaced by a new program, and the function never returns to the caller.