Re: C programming: Is there an exec (with no additional letters) call?
On Wed Jun 18, 2003 at 02:49:26PM +0200, Sebastian Kapfer wrote:
> On Tue, 17 Jun 2003 23:30:15 +0200, Thomas Krennwallner wrote:
> > This code snippet will lookup the PATH environment and search for the
> > "ps" executable. It will execute it and will pass "ps" as argv and
> > "x" as argv. It is equivalent to:
> > $ ps x
> Don't you mean
> $ exec ps x
No, since execlp(3) replaces the current process image with a new
process image. If I run
$ exec ps x
than the shell will be replaced with ps and if ps has run both are gone.
Since this little snippet goes into another process than the shell
itself, only the process calling execlp(3) will be replaced with "ps".
If someone wants the shell to be replaced you have to call exec with the
binary as parameter in the shell(script). There is AFAIK no other way to
.''`. 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