Re: How to tell when execv has succeeded
- From: Maxim Yegorushkin <maxim.yegorushkin@xxxxxxxxx>
- Date: Mon, 12 Jan 2009 03:22:11 -0800 (PST)
On Jan 9, 3:27 am, David Schwartz <dav...@xxxxxxxxxxxxx> wrote:
On Jan 8, 5:37 pm, Barry Margolin <bar...@xxxxxxxxxxxx> wrote:
An operation either succeeds or fails. It cannot half-succeed and half-He was wondering if it could be implemented as follows:
fail.
1. Close all close-on-exec descriptors
2. Load new program into address space
3. Start new program running
If step 2 fails, it returns with an error code, but the descriptors
would still have been closed in step 1, so the parent process would see
EOF from the pipe. The spec says "upon execution", not "upon successful
execution", so this seems like a possible interpretation.
If the 'exec' function is able to make any detectable changes, then it
has not failed and cannot return an error code.
What should it do then? Leave the calling process in uninterruptable
state?
This is the same
reason a 'write' cannot return -1 if it successfully wrote any data.
No function is permitted to leave you in an ambiguous state about what
detectable operations were performed when it returns a failure.
Although this makes perfect sense, where is that guaranteed?
[]
The standard does not specifically have to say that functions may fail
in normal, expected ways without have side-effects one cannot code
around. A typical 'exec' failure is no different than opening a non-
existent file -- the system must be left in a consistent state so
further forward progress can be made.
The are two sides:
* The kernel must be left in a consistent state.
* The user process may be left in an inconsistent state (as
demonstrated by the notorious close() documented behaviour), however,
_exit() must still work as expected, so that the process can terminate
with an observable error and be recycled by the kernel.
--
Max
.
- Follow-Ups:
- Re: How to tell when execv has succeeded
- From: David Schwartz
- Re: How to tell when execv has succeeded
- References:
- How to tell when execv has succeeded
- From: Chris Croughton
- Re: How to tell when execv has succeeded
- From: Mark Wooding
- Re: How to tell when execv has succeeded
- From: Chris Croughton
- Re: How to tell when execv has succeeded
- From: David Schwartz
- Re: How to tell when execv has succeeded
- From: Barry Margolin
- Re: How to tell when execv has succeeded
- From: David Schwartz
- How to tell when execv has succeeded
- Prev by Date: Re: pthread cancelation and mutex
- Next by Date: Re: pthread cancelation and mutex
- Previous by thread: Re: How to tell when execv has succeeded
- Next by thread: Re: How to tell when execv has succeeded
- Index(es):
Relevant Pages
|