--- Begin Message ---
- To: Debian Bug Tracking System <submit@bugs.debian.org>
- Subject: libc6: popen() should return NULL
- From: Jakson Aquino <jaksonaquino@gmail.com>
- Date: Tue, 4 Jul 2006 17:08:19 -0300
- Message-id: <20060704200819.GA12531@localhost.localdomain>
Package: libc6
Version: 2.3.6-15
Severity: normal
Hello,
According to section 15.2 of glibc-doc ("Pipe to a Subprocess") the
function popen() should return NULL if it failed to open the pipe.
However, the function is returning a non NULL pointer, as can be seen
by running the program below:
--------------------------------------
/* testpopen.c */
#include <stdio.h>
int main(){
FILE *F = NULL;
printf("Before: F = %p\n", F);
F = popen("nothing", "w");
printf("After: F = %p\n", F);
pclose(F);
return 0;
}
--------------------------------------
$ gcc testpopen.c
$ ./a.out
Before: F = (nil)
After: F = 0x501010
sh: nothing: command not found
Thanks,
-- System Information:
Debian Release: testing/unstable
APT prefers testing
APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-1-amd64-k8
Locale: LANG=pt_BR.UTF-8, LC_CTYPE=pt_BR.UTF-8 (charmap=UTF-8)
Versions of packages libc6 depends on:
ii tzdata 2006g-2 Time Zone and Daylight Saving Time
libc6 recommends no packages.
-- no debconf information
--- End Message ---
--- Begin Message ---
- To: "Jakson A. Aquino" <jaksonaquino@gmail.com>, "376756-done "@bugs.debian.org
- Subject: Re: Bug#376756: libc6: popen() should return NULL
- From: Aurelien Jarno <aurelien@aurel32.net>
- Date: Thu, 24 Aug 2006 03:18:34 +0200
- Message-id: <44ECFE6A.3090007@aurel32.net>
- In-reply-to: <20060706103446.GA19389@localhost.localdomain>
- References: <20060704200819.GA12531@localhost.localdomain> <20060705130254.GA5124@boogie.lpds.sztaki.hu> <20060706103446.GA19389@localhost.localdomain>
Jakson A. Aquino a écrit :
On Wed, Jul 05, 2006 at 03:02:54PM +0200, Gabor Gombas wrote:
This means that popen() _did_ succeed (it has invoked the shell). The
fact that the shell could not interpret the command and therefore exited
with an error is not popen()'s business anymore.
I'm sorry for reporting the "bug". After your explanation, I could see
that the documentation example is clear enough about popen() return
value.
Ok, closing the bug then.
--
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73
: :' : Debian developer | Electrical Engineer
`. `' aurel32@debian.org | aurelien@aurel32.net
`- people.debian.org/~aurel32 | www.aurel32.net
--- End Message ---