Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!husc6!bbn!aoa!mbr
From: mbr@aoa.UUCP (Mark Rosenthal)
Newsgroups: comp.unix.wizards
Subject: Re: POSIX execlfd and execvfd proposal
Message-ID: <564@aoa.UUCP>
Date: Tue, 1-Dec-87 11:31:57 EST
Article-I.D.: aoa.564
Posted: Tue Dec  1 11:31:57 1987
Date-Received: Fri, 4-Dec-87 06:58:25 EST
References: <18491@linus.UUCP>
Reply-To: mbr@aoa.UUCP (Mark Rosenthal)
Organization: Adaptive Optics Assoc., Cambridge, Mass. USA
Lines: 29

In article <18491@linus.UUCP> ramsdell@linus.UUCP (John D. Ramsdell) writes:
>In writing programs that dynamically load code, one usually needs to
>know from which file the executing image was exec'ed.  I conclude from
>my own review of Draft 12 of the POSIX standard (P1003.1), that there
>is no way of knowing this information.  What do you think about adding
>the following two system calls, execlfd and execvfd?

He then goes on to describe system calls which would provide the exec'ed program
with a file descriptor which could be used to read the file.

You've identified a real problem, but your proposed solution puts the
responsibility in the wrong place.  If you implement execlfd and execvfd as
described, the exec'er (i.e. the program calling exec??()) must determine
whether or not the exec'ee (i.e. the program called by exec??()) will want
to dynamically load code, in order to know whether to call execl() or
execlfd().  This allows the possibility of a situation in which the exec'er
uses execl() when it should have used execlfd().  Thus boot_fd would not get
initialized, and when the exec'ee tries to read the file from which it was
exec'ed, the read fails, with potentially disastrous consequences for the
exec'ee.

A better design is to prevent the situation from ever arising.  The system
call should be the same regardless of whether or not the exec'ed file
dynamically loads code.  The desired result could be achieved by adding a
new special file (and device driver) which any program could open to read
the file from which it was exec'ed.
-- 
	Mark of the Valley of Roses
	...!{harvard,ima}!bbn!aoa!mbr