* popen2 popen call
@ 2009-08-27 12:12 F. Heitkamp
2009-08-27 12:40 ` Andreas Schwab
0 siblings, 1 reply; 7+ messages in thread
From: F. Heitkamp @ 2009-08-27 12:12 UTC (permalink / raw)
To: linux-kernel
Hi,
I am using vanilla kernel 2.6.31-rc7, glibc 2.10.x on a Core 2 Duo system.
When the popen call is made in sshd/session.c I get a error from strerror
of "Function not Implemented". I googled a bit and found that there is
sometimes an problem between the way the kernel and glibc are compiled
that causes glibc not to find the popen2 call in the kernel. The fix
seemed to imply I need a certain processor choice when compiling the
kernel.
Strangely, simple popen test programs seem to work OK.
Can anyone shed some light on this for me? I would like to get this to
work, so my X11 forwarding works in ssh.
BTW, kernels before 2.6.27 don't seem to cause the problem to manifest
itself.
Thanks!
Fred
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: popen2 popen call
2009-08-27 12:12 popen2 popen call F. Heitkamp
@ 2009-08-27 12:40 ` Andreas Schwab
2009-08-27 18:39 ` heitkamp
0 siblings, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2009-08-27 12:40 UTC (permalink / raw)
To: heitkamp; +Cc: linux-kernel
"F. Heitkamp" <heitkamp@ameritech.net> writes:
> When the popen call is made in sshd/session.c I get a error from
> strerror of "Function not Implemented".
Which function exactly returns this error?
> I googled a bit and found that there is sometimes an problem between
> the way the kernel and glibc are compiled that causes glibc not to
> find the popen2 call in the kernel.
There is no such thing as a popen2 syscall.
Andreas.
--
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E
"And now for something completely different."
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: popen2 popen call
2009-08-27 12:40 ` Andreas Schwab
@ 2009-08-27 18:39 ` heitkamp
2009-08-27 19:15 ` Ulrich Drepper
0 siblings, 1 reply; 7+ messages in thread
From: heitkamp @ 2009-08-27 18:39 UTC (permalink / raw)
To: Andreas Schwab; +Cc: linux-kernel
-------------- Original message from Andreas Schwab <schwab@redhat.com>: --------------
> "F. Heitkamp" writes:
>
> > When the popen call is made in sshd/session.c I get a error from
> > strerror of "Function not Implemented".
>
> Which function exactly returns this error?
In the openssh source distribution there is a file, session.c that uses popen, with the
ultimate purpose of fixing the .Xauthority file for X11 forwarding. It uses popen to set the DISPLAY, MIT-MAGIC-COOKIE etc. via the shell I think, executing xauth. In session.c popen is used three times under different conditions. I put strerror calls where the popen call returns a NULL pointer to try to find out why the popen call fails. I could post the section of code if you want to see. I am not a professional programmer.
The gist of it is:
fp = popen( cmdstr, "w" );
if ( !fp )
/* call strerror, errno */
>
> There is no such thing as a popen2 syscall.
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.
Fred
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: popen2 popen call
2009-08-27 18:39 ` heitkamp
@ 2009-08-27 19:15 ` Ulrich Drepper
2009-09-05 17:39 ` F. Heitkamp
0 siblings, 1 reply; 7+ messages in thread
From: Ulrich Drepper @ 2009-08-27 19:15 UTC (permalink / raw)
To: heitkamp; +Cc: Andreas Schwab, linux-kernel
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: popen2 popen call
2009-08-27 19:15 ` Ulrich Drepper
@ 2009-09-05 17:39 ` F. Heitkamp
2009-09-06 8:55 ` Ulrich Drepper
0 siblings, 1 reply; 7+ messages in thread
From: F. Heitkamp @ 2009-09-05 17:39 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: Andreas Schwab, linux-kernel
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);
}
}
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-09-09 12:51 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2009-09-06 8:55 ` Ulrich Drepper
2009-09-09 12:47 ` F. Heitkamp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox