0

Assuming that I decide, for some reason, to never use the syscall wait ever again in any of the programs I write.
Does it mean that my memory will be cluttered with all the finished processes that their father didn't wait for?

This is a part of an academic assignment and I find the question a bit perplexing because both answered sound acceptable to me.

This is how I answered this and I simply want feedback if that's indeed true.

If the father process doesn't wait for his children before exiting - these children will be linked to the init process on the exit call (inside the function forget_original_parent())on the father process.
At some point, the init process will hold more processes than it can - regarding memory limits.
So not calling wait is indeed cluttering the memory.

Also, I would love clarification on what happens in this case? does the machine shuts down and exits the init process? what happened to all of the children of init if that's the case?

1

At some point, the init process will hold more processes than it can - regarding memory limits.

Not quite: zombie processes (processes which have exited but haven’t been reaped) don’t occupy memory in their parent process; they occupy memory in the kernel’s process table.

If your init is a “standard” init, it will reap zombie processes anyway, and you won’t run into any issues.

If your init also ignores child processes, it still won’t run into limits which could cause it to be killed. The main limit which will come into play is the maximum number of processes; reaching that will prevent new processes from being created, which will immediately cause problems (processes are constantly being created). The system will keep on running, but you won’t be able to log in, and you’ll only be able to use existing shells etc.

3
  • Surely this only applies as long as the original parent continues to run, create new children, and ignore SIGCLD? Unless the parent runs forever, when it dies all its children will be reparented to init, which should dispose of such children promptly. Nov 29 '20 at 15:28
  • Yes; I somehow assumed that the OP intended to write a child-ignoring init too, but that’s reading too much into the question. Nov 29 '20 at 16:04
  • 1
    What i like to add to this answer is that zombies take up very little memory space. The prime reason for zombies to exist is to retain its exit status and resource usage counters so some other process can read these. The memory usage of a zombie is basically a kernel proc structure.
    – ctrl-d
    Nov 29 '20 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.