CS FundamentalsHardGATE CS · Amazon/Microsoft SDE MCQ
A process writes to a pipe whose read end has been closed by every process. What happens by default?
- A. The write blocks until some process opens the read end
- B. The data is discarded and write() returns the byte count
- C. The writer receives SIGPIPE, which terminates it by default
- D. write() returns 0 to signal end of file
Correct answer: C. The writer receives SIGPIPE, which terminates it by default
With no readers left, write() raises SIGPIPE; if the signal is ignored or caught, write() fails with EPIPE instead. End of file (read returning 0) is what a READER sees when all write ends are closed.
More Operating Systems questions
- A device raises 10,000 interrupts per second, and each interrupt costs 50 µs of CPU time to enter, service and return. What fraction of…
- A file is stored with linked allocation (each block holds a pointer to the next) and nothing is cached. How many disk reads does it take…
- Requests arrive at a server at 20 per second, and Little's law applies in steady state. If on average 6 requests are in the system, what…
- Pages are 4 KB and a process has 3 frames. It runs for (i = 0; i < 1024; i++) for (j = 0; j < 1024; j++) A[i][j] = 0; on an int…
- Which statement about the difference between an unsafe state and a deadlocked state (Banker's algorithm) is correct?
- A 32-bit system uses segmentation with paging. A logical address is (segment s, offset d) with d of 32 bits; within a segment, d is split…