commands within ``make''

Guy Harris guy at rlgvax.UUCP
Sun Feb 17 06:29:40 AEST 1985


> Is there a good reason why an option cannot be added
> to ``make'' so that it will directly execute subcommands
> such as the compiler, instead of invoking a subshell?

Stu Feldman thought it was a good idea - that's why he put it into "make"
when he wrote it.  The following code comes from "dosys.c", V7/4.2BSD version;
the System III and System V versions do the same thing:

	if(metas(comstring))
		status = doshell(comstring,nohalt);
	else	status = doexec(comstring);

"doshell" does an "sh -c", and "doexec" chops the command string up itself
and does a "fork" and "exec".

> The only reason I can think of is to allow shell syntax
> such as pipes.

"metas()" returns 1 if the string contains any shell meta-characters (like
'|' for pipes), and 0 otherwise.

> Some tests indicate that a vfork() and execvp() go about twice as
> fast as a system().

Not surprising, considering you don't have to fire up "/bin/sh".  However,
neither version of "make" uses "vfork" - it uses "fork" instead, probably
because the child fiddles with various things before execing.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.unix mailing list