What call before a fork

process

A long while ago I went to a job interview with a thoroughly weird company in London who claimed to be expert Unix consultants. Anyway these people were complete nutters and not surprisingly the company doesn't seem to be there any more, but at the interview they asked me the following question:

What is the first call you make to start a new process?

So I answered that the first call is fork. The two people interviewing me said (very insistently, as if I'd missed something utterly obvious)

What call do you do before you do the fork?

Now, I have no idea about this question, and I have to say these people convinced me they were unmitigated idiots for reasons completely unrelated to this question, but for some reason this question still bugs me even now. Is there some call which is made before a fork? Is there some subtlety I missed out on?

Best Answer

I hesitate to put this as an answer as one can only guess, but:

  1. flush stdout in case the child is going to do output prior to exec.
  2. close any open file descriptors greater than 2 assuming that the new process is expecting a "standard" environment as it would get from the shell.
  3. some obscure thing required by some obscure variant like Eunice that they though very clever of themselves to know.

Any way you scratch it, asking an obscure factual question is no way to derive anything about a candidate except perhaps how they respond to stupid questions.