Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need help with fork and execl calls.

390 views
Skip to first unread message

Michael Barre

unread,
Aug 21, 1999, 3:00:00 AM8/21/99
to
am having trouble with my execl calls failing inconsistantly after a
fork. Can anyone help?

Here's the senario:
I have the program fork 5 times, each fork then runs execl. As each
child dies I start another, so I always have 5 running. The first child
runs the execl no problem, then the next 4 fail with errno 14: Bad
Address (man execve says: EFAULT filename points outside your
accessible address space.) Then the next one works and the next 4 fail.

I tried dropping it to just one child and got no error. I upped it to
two children and every other one fails.

What am I doing wrong?
thanks,
mike
bar...@strickland.com


Jun Sawada

unread,
Aug 21, 1999, 3:00:00 AM8/21/99
to
Michael Barre wrote:

> Here's the senario:
> I have the program fork 5 times, each fork then runs execl. As each
> child dies I start another, so I always have 5 running. The first child
> runs the execl no problem, then the next 4 fail with errno 14: Bad
> Address (man execve says: EFAULT filename points outside your
> accessible address space.) Then the next one works and the next 4 fail.
>
> I tried dropping it to just one child and got no error. I upped it to
> two children and every other one fails.
>

Man page of execl says

The const char *arg and subsequent ellipses in the execl,
execlp, and execle functions can be thought of as arg0,
arg1, ..., argn. Together they describe a list of one or
more pointers to null-terminated strings that represent
the argument list available to the executed program. The
first argument, by convention, should point to the file
name associated with the file being executed. The list of
arguments must be terminated by a NULL pointer.

I bet you did not put a NULL at the end of the arguments, that is why
execl is trying to read an argument string from an address that is read
protected. Put 0 or NULL after listing arguments like:
execl("ls","ls","-l",NULL).

-- Jun Sawada
saw...@cs.utexas.edu

Michael Barre

unread,
Aug 22, 1999, 3:00:00 AM8/22/99
to
Jun Sawada wrote:

Thanks, it works.
I feel kind of stupid now...RTFB!

Michael Barre

unread,
Aug 22, 1999, 3:00:00 AM8/22/99
to
0 new messages