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

Re: C programming: Is there an exec (with no additional letters) call?


On Tue Jun 17, 2003 at 10:29:25PM +0300, Shaul Karl wrote:
>   I was told that similar to execl, execlp et al there is also an exec
> call. Yet when I run 
>     man exec

This is exec(3) which documents the exec family calls. AFAIK there is no
POSIX exec() function. Please install the glibc-doc package which
includes the info pages of GNU libc. This documenation is far better
than the rudimentary man pages (if you know what you're doing the man
pages ARE better, but ...).

> I only get execl, execlp, execle, execv and execvp. No `pure' exec, one
> without any additional letters. Can I safely tell that person that he is
> definitely confusing the C system calls with shell or another
> interpreted language? If not, what arguments does exec takes, what is
> the return code and where is it documented?

exec is a bash builtin. If you want to simulate it in C try this code:

	/* always include the calling filename of the prog as
	 * 2nd parameter to execlp as it's evaluated as argv[0]
	 * in the resulting process
	execlp ("ps", "ps", "x", NULL);
	/* if we are here, there was an error */
	perror ("execlp failed");
	exit (1);

This code snippet will lookup the PATH environment and search for the
"ps" executable. It will execute it and will pass "ps" as argv[0] and
"x" as argv[1]. It is equivalent to:

$ ps x

So long

 .''`.  Obviously we do not want to leave zombies around. - W. R. Stevens
: :'  : Thomas Krennwallner <djmaecki at ull dot at>
`. `'`  1024D/67A1DA7B 9484 D99D 2E1E 4E02 5446  DAD9 FF58 4E59 67A1 DA7B
  `-    http://bigfish.ull.at/~djmaecki/

Reply to: