Ulrich Drepper wrote:
> On Thu, Aug 27, 2009 at 11:39,<[email protected]> wrote:
>
>> OK. I read in one of the messages, that glibc, passes the popen call to a ABI in the kernel. I have not
>> looked at the code in glibc yet.
>>
>
> popen uses pipe2. There is fallback code to use pipe if necessary.
> It's compiled out only of the libc assumes the kernel support is
> available.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
>
OK. I think I found the problem but how do I fix it?
Did I miss a kernel config option?
I got the code from the man page:
http://linux.die.net/man/2/pipe
http://manpages.courier-mta.org/htmlman2/pipe.2.html
bash-4.0$ gcc -o linux-pipe linux-pipe.c
/tmp/ccHHOYkD.o: In function `main':
linux-pipe.c:(.text+0x3b): warning: warning: pipe2 is not implemented
and will always fail
bash-4.0$ ./linux-pipe ls
pipe: Function not implemented
bash-4.0$
#include <sys/wait.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int
main(int argc, char *argv[])
{
int pfd[2];
pid_t cpid;
char buf;
assert(argc == 2);
if (pipe2(pfd) == -1) { perror("pipe"); exit(EXIT_FAILURE); }
cpid = fork();
if (cpid == -1) { perror("fork"); exit(EXIT_FAILURE); }
if (cpid == 0) { /* Child reads from pipe */
close(pfd[1]); /* Close unused write end */
while (read(pfd[0], &buf, 1) > 0)
write(STDOUT_FILENO, &buf, 1);
write(STDOUT_FILENO, "\n", 1);
close(pfd[0]);
_exit(EXIT_SUCCESS);
} else { /* Parent writes argv[1] to pipe */
close(pfd[0]); /* Close unused read end */
write(pfd[1], argv[1], strlen(argv[1]));
close(pfd[1]); /* Reader will see EOF */
wait(NULL); /* Wait for child */
exit(EXIT_SUCCESS);
}
}
On Sat, Sep 5, 2009 at 10:39, F. Heitkamp<[email protected]> wrote:
> linux-pipe.c:(.text+0x3b): warning: warning: pipe2 is not implemented and
> will always fail
you will get this warning if the glibc you're using was compiled
without appropriate kernel headers. I.e., the definition of
__NR_pipe2 wasn't available.
Ulrich Drepper wrote:
> On Sat, Sep 5, 2009 at 10:39, F. Heitkamp<[email protected]> wrote:
>
>> linux-pipe.c:(.text+0x3b): warning: warning: pipe2 is not implemented and
>> will always fail
>>
>
> you will get this warning if the glibc you're using was compiled
> without appropriate kernel headers. I.e., the definition of
> __NR_pipe2 wasn't available.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
>
Compiling glibc with newer headers worked! Thank you all.
Fred