1/17
Practice questions and answers based on the lecture covering pipe system calls, file descriptor management, process inheritance, and the UQ Make Light assignment overview.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What arguments must be passed to the pipe system call?
An array of two integers.
In a pipe array, which index represents the read end and which represents the right end?
The first entry (index 0) is the read end and the second entry (index 1) is the write end.
What command is used to view user settable limits, such as the maximum number of open files?
ulimit−a
What is the standard maximum number of open file descriptors for most user accounts mentioned in the lecture?
1024
Why is it critical for each process to close the unused end of a pipe after a fork?
To ensure that the reading end can correctly detect the end of file (EOF) once the last writer closes its descriptor.
What does the wait(NULL) system call accomplish in the parent process?
It waits for any child process to finish and reaps it.
What is the result of using printf with a percent s format on a buffer containing null terminators mid-stream?
It will stop printing at the first null terminator, treating it as the end of the string.
What utility can be used to attach to a running process and witness its system calls?
strace−p<PID>
Where in the Linux virtual file system can you find information about the file descriptors open by process ID 3643579?
(ls−l)/proc/3643579/fd
What function allows for formatted printing directly to a file descriptor instead of a file stream?
dprintf
Which system call is used to duplicate a file descriptor and redirect it to standard input or output?
dup2
What happens to a child process if its parent finishes first?
It becomes an orphan process and is inherited by process ID 1, which reaps it immediately upon completion.
What signal is sent to a process if it attempts to write to a pipe with no active reading end?
SIGPIPE (often resulting in exit code 141).
Which function converts an existing file descriptor into a wrapper file stream (FILE∗)?
fdopen
Which function is used to retrieve the underlying file descriptor from a file handle?
fileno
Why is calling fdopen inside a function and losing track of the pointer dangerous?
It results in memory leaks and potential data loss because the associated buffer may contain unconsumed data from the file descriptor.
In the context of the UQ Make Light assignment, what system call is used to check for a file's existence and modification timestamp?
stat
In a shell environment, which command’s exit status is typically reported for a pipeline of multiple commands?
The exit status of the last command in the pipe.