From: "Steve Graegert" <graegerts@gmail.com>
To: Prasanta Sadhukhan <Prasanta.Sadhukhan@sun.com>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: execv fails with EFAULT
Date: Wed, 7 Mar 2007 13:46:25 +0100 [thread overview]
Message-ID: <6a00c8d50703070446s26ddb847uae5697ed797a2ff0@mail.gmail.com> (raw)
In-Reply-To: <45EEA7F8.5080908@sun.com>
On 3/7/07, Prasanta Sadhukhan <Prasanta.Sadhukhan@sun.com> wrote:
> Hi,
>
> When I tried the following program
> void test4()
> {
> printf("doing execv\n");
> if(execv("/bin/ls", "-l") == -1)
> printf("exec failed with errno %d\n", errno);
> else
> printf("exec succeed\n");
> }
Prasanta,
A NULL terminated array of arguments must be passed to execv(2) as the
prototype indicates: int execv(const char *path, char *const argv[]);
For example:
#include <unistd.h>
char *cmd[] = { "ls", "-l", NULL };
int result = execv ("/bin/ls", cmd);
An error of EFAULT usually means that an argument points to an illegal address.
\Steve
--
Steve Grägert <steve@graegert.com>
Jabber xmpp://graegerts@jabber.org
Internet http://eth0.graegert.com, http://blog.graegert.com
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2007-03-07 12:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-07 11:54 execv fails with EFAULT Prasanta Sadhukhan
2007-03-07 12:46 ` Steve Graegert [this message]
2007-03-07 13:14 ` Prasanta Sadhukhan
2007-03-07 13:50 ` Steve Graegert
2007-03-07 16:58 ` Glynn Clements
2007-03-07 14:20 ` Mathieu Dube
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6a00c8d50703070446s26ddb847uae5697ed797a2ff0@mail.gmail.com \
--to=graegerts@gmail.com \
--cc=Prasanta.Sadhukhan@sun.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).