Date: Tue, 17 Mar 2009 04:20:03 GMT From: Nate Eldredge <neldredge@math.ucsd.edu> To: freebsd-bugs@FreeBSD.org Subject: Re: amd64/132677: error calling fork execvp Message-ID: <200903170420.n2H4K3uU076803@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/132677; it has been noted by GNATS. From: Nate Eldredge <neldredge@math.ucsd.edu> To: ron <rzo@gmx.de> Cc: freebsd-gnats-submit@freebsd.org, freebsd-amd64@freebsd.org Subject: Re: amd64/132677: error calling fork execvp Date: Mon, 16 Mar 2009 20:53:49 -0700 (PDT) On Sun, 15 Mar 2009, ron wrote: > hello, > > calling execvp(2) works fine. > > however calling > > pid = fork() > if (pid == 0) > execvp(2) > > returns error 22 (invalid value) > > calling > > pid = fork() > if (pid == 0) > execve(3) > > works fine Can you be more specific? In particular, could you send a complete source that can be compiled and run, and that shows the problem? I can't reproduce a problem here. I am running 7.1 on amd64, and the following program works as expected. #include <unistd.h> #include <stdio.h> #include <sys/types.h> #include <sys/wait.h> #include <stdlib.h> int main(void) { pid_t pid; pid = fork(); if (pid == 0) { char *argv[] = { "echo", "Hello, world!", NULL }; execvp("echo", argv); perror("execvp failed"); _exit(1); } else if (pid > 0) { int status; if (waitpid(pid, &status, 0) == -1) { perror("waitpid"); exit(1); } if (WIFEXITED(status)) printf("Child exited with status %d\n", WEXITSTATUS(status)); else if (WIFSIGNALED(status)) printf("Child killed by signal %d\n", WTERMSIG(status)); else printf("Impossible status!\n"); } else if (pid < 0) { perror("fork"); exit(1); } return 0; } The output is: Hello, world! Child exited with status 0 Perhaps there is something wrong in a different part of your test program. -- Nate Eldredge neldredge@math.ucsd.edu
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903170420.n2H4K3uU076803>