I was looking at another question (https://stackoverflow.com/q/47845/537980), and saw an answer, about how much set up this other OS had to do, for every Process Create.

I got wondering. Would it be possible to do the setup (once, then fork), then do a partial exec to load the variable parts? That is only part of the process should be replaced.

A specific example of partial, would be. We want to load some execution environment, then exec to replace the loader, but not the environment. So this is taking control of what gets replaced (I know that exec does not replace everything (e.g. it keeps a COW of the file descriptor table)).

I realise that this may not have any practical use, as fork and exec are relatively cheep on many Unixes.

  • You didn't explain what a partial exec is. Exec preserve some attributes of a thread, like your namespace, file descriptors, session relationship, tid. – 炸鱼薯条德里克 Jan 10 at 14:13
  • I have made some improvements to the question, and my answer (based on feedback, received so far). – ctrl-alt-delor Jan 10 at 14:35
  • 2
    You should untie the fork and exec from each other in your mind; of course you can do a "partial exec"; you mmap(PROT_EXEC) pages from another file into your address space, jump into them, and yuppie! "partial exec". I don't know if you can replicate everything exec does in userspace -- but you certainly can replicate most of it. – pizdelect Jan 10 at 14:54
  • @pizdelect, thanks. Could you write up an answer: that is the sort of thing I am looking for. – ctrl-alt-delor Jan 10 at 19:50

Partial answer of an untested idea.

Open files by name, exec, you still have the handles to the files, so mmap them.

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.