From: "F. Heitkamp" <heitkamp@ameritech.net>
To: Ulrich Drepper <drepper@gmail.com>
Cc: Andreas Schwab <schwab@redhat.com>, linux-kernel@vger.kernel.org
Subject: Re: popen2 popen call
Date: Sat, 05 Sep 2009 13:39:35 -0400 [thread overview]
Message-ID: <4AA2A257.3000409@ameritech.net> (raw)
In-Reply-To: <a36005b50908271215v27f06476p5808b9fb6b19fa81@mail.gmail.com>
Ulrich Drepper wrote:
> On Thu, Aug 27, 2009 at 11:39,<heitkamp@ameritech.net> 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 majordomo@vger.kernel.org
> 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);
}
}
next prev parent reply other threads:[~2009-09-05 17:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-27 12:12 popen2 popen call F. Heitkamp
2009-08-27 12:40 ` Andreas Schwab
2009-08-27 18:39 ` heitkamp
2009-08-27 19:15 ` Ulrich Drepper
2009-09-05 17:39 ` F. Heitkamp [this message]
2009-09-06 8:55 ` Ulrich Drepper
2009-09-09 12:47 ` F. Heitkamp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AA2A257.3000409@ameritech.net \
--to=heitkamp@ameritech.net \
--cc=drepper@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=schwab@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox