execve() leads to "memory fault"? - Minix
This is a discussion on execve() leads to "memory fault"? - Minix ; Hi Folks,
I am using Minix3 and try to run a test program for execve as root and
normal user. Both get "memory fault". My code is as follows:
#include
int main()
{
char *argv[3];
argv[0] = "bin/cat";
argv[1] = ...
-
execve() leads to "memory fault"?
Hi Folks,
I am using Minix3 and try to run a test program for execve as root and
normal user. Both get "memory fault". My code is as follows:
#include
int main()
{
char *argv[3];
argv[0] = "bin/cat";
argv[1] = "/etc/passwd";
argv[2] = 0;
execve("/bin/cat", argv, 0);
return 0;
}
The code works fine on Fedora Core 6.
What is the difference between Minix3 and Linux on execve(). I read
the manula page, but can't find the difference.
Thanks.
-
Re: execve() leads to "memory fault"?
"TowerGee" writes:
> Hi Folks,
>
> I am using Minix3 and try to run a test program for execve as root and
> normal user. Both get "memory fault". My code is as follows:
>
> #include
>
> int main()
> {
> char *argv[3];
> argv[0] = "bin/cat";
> argv[1] = "/etc/passwd";
> argv[2] = 0;
>
> execve("/bin/cat", argv, 0);
The 3rd parameter should be the environment pointer. A pointer to a
(char*) 0 should be OK, but I think that Linux process execvw with a 0
pointer for envp is outside of the spec (w/o having checked that in
POSIX -- please do so yourself.
You could try
char* envp[1];
...
envp[0] = 0;
...
execve("/bin/cat", argv, envp);
>
> return 0;
> }
>
> The code works fine on Fedora Core 6.
> What is the difference between Minix3 and Linux on execve(). I read
> the manula page, but can't find the difference.
>
> Thanks.
Just giving feedback, wether it worked for you now, would be (a) a
courtesy to me, who is answering your question, (b) nice to the people
reading and searching list and group archives after you. Just a HINT.
Regards -- Markus
-
Re: execve() leads to "memory fault"?
Thanks! It works now. It seems that it is really a slight
difference. 
On Feb 9, 5:48 pm, Markus E Leypold
wrote:
> "TowerGee" writes:
> > Hi Folks,
>
> > I am using Minix3 and try to run a test program forexecveas root and
> > normal user. Both get "memory fault". My code is as follows:
>
> > #include
>
> > int main()
> > {
> > char *argv[3];
> > argv[0] = "bin/cat";
> > argv[1] = "/etc/passwd";
> > argv[2] = 0;
>
> > execve("/bin/cat", argv, 0);
>
> The 3rd parameter should be the environment pointer. A pointer to a
> (char*) 0 should be OK, but I think that Linux process execvw with a 0
> pointer for envp is outside of the spec (w/o having checked that in
> POSIX -- please do so yourself.
>
> You could try
>
> char* envp[1];
> ...
> envp[0] = 0;
> ...
> execve("/bin/cat", argv, envp);
>
>
>
> > return 0;
> > }
>
> > The code works fine on Fedora Core 6.
> > What is the difference between Minix3 and Linux onexecve(). I read
> > the manula page, but can't find the difference.
>
> > Thanks.
>
> Just giving feedback, wether it worked for you now, would be (a) a
> courtesy to me, who is answering your question, (b) nice to the people
> reading and searching list and group archives after you. Just a HINT.
>
> Regards -- Markus