From nobody@FreeBSD.org  Sun Mar 15 22:51:50 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2CC8C106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 15 Mar 2009 22:51:50 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 024258FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 15 Mar 2009 22:51:50 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n2FMpnQs014353
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 15 Mar 2009 22:51:49 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n2FMpnRk014352;
	Sun, 15 Mar 2009 22:51:49 GMT
	(envelope-from nobody)
Message-Id: <200903152251.n2FMpnRk014352@www.freebsd.org>
Date: Sun, 15 Mar 2009 22:51:49 GMT
From: ron <rzo@gmx.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: error calling fork execvp
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         132677
>Category:       kern
>Synopsis:       [libc] error calling fork execvp
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gavin
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Mar 15 23:00:04 UTC 2009
>Closed-Date:    Thu Apr 16 09:44:42 UTC 2009
>Last-Modified:  Thu Apr 16 09:44:42 UTC 2009
>Originator:     ron
>Release:        7.1 amd64
>Organization:
>Environment:
FreeBSD bsd64.ARBEITSGRUPPE 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan  1 08:58:24 UTC 2009     root@driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
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

- Ron
>How-To-Repeat:

>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-amd64->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue Mar 17 02:36:53 UTC 2009 
Responsible-Changed-Why:  
Probably not amd64-specific. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=132677 

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
State-Changed-From-To: open->feedback 
State-Changed-By: gavin 
State-Changed-When: Fri Apr 10 09:13:20 UTC 2009 
State-Changed-Why:  
Submitter was asked for feedback 


Responsible-Changed-From-To: freebsd-bugs->gavin 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Fri Apr 10 09:13:20 UTC 2009 
Responsible-Changed-Why:  
Track 

http://www.freebsd.org/cgi/query-pr.cgi?pr=132677 
State-Changed-From-To: feedback->closed 
State-Changed-By: gavin 
State-Changed-When: Thu Apr 16 09:42:50 UTC 2009 
State-Changed-Why:  
Submitter is happy for this to be closed: It appears to actually be 
a java issue. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=132677 
>Unformatted:
