From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111122 invoked by alias); 19 May 2015 20:34:33 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Received: (qmail 111065 invoked by uid 48); 19 May 2015 20:34:30 -0000 From: "nachms+sourceware at gmail dot com" To: glibc-bugs@sourceware.org Subject: [Bug libc/18433] New: posix_spawn does not return correctly upon failure to execute Date: Tue, 19 May 2015 20:34:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: 2.19 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: nachms+sourceware at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-05/txt/msg00169.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=18433 Bug ID: 18433 Summary: posix_spawn does not return correctly upon failure to execute Product: glibc Version: 2.19 Status: NEW Severity: normal Priority: P2 Component: libc Assignee: unassigned at sourceware dot org Reporter: nachms+sourceware at gmail dot com CC: drepper.fsp at gmail dot com Target Milestone: --- posix_spawn is supposed to return a value indicating an error when it fails. The specification for it is here: http://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html >>From the spec: Otherwise, no child process shall be created, the value stored into the variable pointed to by a non-NULL pid is unspecified, and *an error number shall be returned as the function return value* to indicate the error. However, glibc is returning 0 (success) instead of some kind of indication of error (such as 2 for ENOENT). Test program: ------------------------- #include #include int main() { extern char **environ; char *argv[] = { "/bin/blah_blah-blah", 0 }; pid_t pid = -1; int ret = posix_spawn(&pid, argv[0], 0, 0, argv, environ); printf("ret: %d\npid: %ld\n", ret, (long)pid); return(0); } ------------------------- "/bin/blah_blah-blah" doesn't exist, so it should not successfully spawn. GLIBC for this program is returning: ret: 0 pid: 17302 FreeBSD, DragonFlyBSD, NetBSD, and musl-libc all handle this correctly. With them: ret: 2 pid: -1 (some will put a different value here, which is allowed by the standard) -- You are receiving this mail because: You are on the CC list for the bug.