A bad thing about ALFS in c

Felipe Contreras al593181 at mail.mty.itesm.mx
Tue Nov 6 18:39:29 PST 2001


On Tue, Nov 06, 2001 at 11:09:57PM +0100, Matthias Benkmann wrote:
> On 5 Nov 2001, at 20:41, Felipe Contreras wrote:
> 
> > On Mon, Nov 05, 2001 at 04:14:27PM -0800, John Schmerge wrote:
> > > Why not just use system(3) ?
> > 
> > Let's supose you want to execute this.
> > 
> >  export LFS=/mnt/lfs
> >  cd $LFS
> >  ls
> > 
> > If you run each command in a separated system() call, then each of them
> > will be executed in a subshell, so in the second system command the
> > environment variable LFS will be cleared, also on the third command the
> > working directory will be the same as where you started before the cd $LFS
> > command. So the commands are not executed on the same shell.
> > 
> > If you run the commands as a whole in the same subshell then if it fails
> > you can't know on which command the shell failed. Let's suppose 'cd $LFS'
> > exited with an error because that directory didn't existed. So with system
> > you can't really interact with the shell, just tell what to do.
> 
> What would you do with the information which command failed? Unless you 
> can code the most advance AI in existence there's probably nothing you can 
> do to automatically recover from such an error. I think aborting and 
> passing on the error messages to the user is the best thing you can do.

Well, probably I whould only save the last step that was executed and
pass it to the user, might be with the proper error message. But in
order to do that you need to know where the shell exited, and that
can't be done simply by execv() or system() or anything except a
coshell or with separated environmental commands as John Schmerge
purposed.
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe alfs-discuss' in the subject header of the message



More information about the alfs-discuss mailing list