[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nmh-workers] outstanding patches

From: Robert Elz
Subject: Re: [Nmh-workers] outstanding patches
Date: Thu, 26 May 2005 15:31:49 +0700

    Date:        Wed, 25 May 2005 22:48:13 +0200
    From:        Harald Geyer <address@hidden>
    Message-ID:  <address@hidden>

  | Sorry, but you are wrong. If this was the case, I would have written the
  | bug report along the lines of "Please work around the broken linux
  | vfork()". But out of reason I didn't.


  | But BTW IIRC there is no guarantee that this "requirement" is met in the
  | standards. Ie #define vfork() fork() is a valid implementation.

Yes.   While the processes share address space, the parent blocks.  Once
that has ceased, either via exit (no more child), exec (whole new address
space for child) or because they never did share (using fork()) the parent
can continue.   The kernel gets to decide when that happens, a process
using vfork() cannot depend upon any of it.

  | Obviously nmh does depend upon errno being unchanged, so it's the fault
  | of nmh itself not linux.

That would be correct.   In that case one might wonder though why the bug
is only observed under linux?

I haven't seen the bug report, would you care to indicate exactly where
the problem occurs (and the symptoms observed) ?   (Private mail if you

  | (Indeed I overlooked, that this is 
  | a bug even if fork() is used instead.

It would be, yes, though the bug might be harder to spot, as fork()
when it succeeds most probably doesn't alter errno.

  | However, I guess it's still a bad
  | idea to use any syscalls between vfork() and exec() - so actually it's
  | two bugs to be fixed...)

No, sys calls are generally fine (it does depend what they do, read() would
not be a good idea... except perhaps into a local buffer in a function
called by the child process) - in fact, sys calls are expected, the child
has a new open file table already, and is allowed to manipulate that, and
usually is expected to manipulate that, before the exec.   What is generally
required though is that only genuine sys calls be used (e.g. even though I
mentioned exit(), I really meant the sys call exit(2), not the libc exit(3).
After a vfork, before exec, the child generally needs to use _exit() to avoid
fooling with the parent's stdio structures).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]