CS FundamentalsModerateGATE CS · Amazon/Microsoft SDE MCQ

Which statement about a process that calls exec() successfully is correct?

  1. A. It gets a new process ID but keeps its open files and heap
  2. B. It keeps its PID and open descriptors, but code, data, heap and stack are replaced
  3. C. It runs the new program as a child and resumes after it finishes
  4. D. It keeps its old heap so the new program can read the old data

Correct answer: B. It keeps its PID and open descriptors, but code, data, heap and stack are replaced

exec replaces the program image within the same process: the PID, parent and open descriptors survive, while text, data, heap and stack are rebuilt. It returns only on failure; creating a child is fork's job.

More Operating Systems questions

Exams that ask this topic