popen3 and spawn

H

Hal Fulton

When I invoke telnet with PTY.spawn, I can easily send it the
"attention" character ^] resulting in a telnet> prompt.

When I invoke it with Open3.popen3, this doesn't work.

Can someone tell me why?


Thanks,
Hal
 
S

Steven Jenkins

Hal said:
When I invoke telnet with PTY.spawn, I can easily send it the
"attention" character ^] resulting in a telnet> prompt.

When I invoke it with Open3.popen3, this doesn't work.

Can someone tell me why?

I'd guess it's because the pipe is buffered. Try IO#flush or IO#sync.

Steve
 
H

Hal Fulton

Steven said:
Hal said:
When I invoke telnet with PTY.spawn, I can easily send it the
"attention" character ^] resulting in a telnet> prompt.

When I invoke it with Open3.popen3, this doesn't work.

Can someone tell me why?


I'd guess it's because the pipe is buffered. Try IO#flush or IO#sync.

A reasonable guess, but it doesn't work for me.


Thanks,
Hal
 
E

evanm

Forgive me if I don't explain this fully (I'm far from an expert), but the
reason ^] works in telnet is because it is a tty. Telnet calls an ioctl on
its stdout that causes ^] to have special meaning, and later make telnet
return from a select() to hand out the telnet> prompt. ioctl doesn't work on
any files, just "character special files" according to the manpage. When you
use popen the ioctl fails because you're not calling it on a terminal,
you're calling it on a regular pipe.

So basically if you want that behavior you need to put it through a
terminal, because the ioctl is what makes that happen and the ioctl requires
a terminal.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,147
Messages
2,570,833
Members
47,380
Latest member
AlinaBlevi

Latest Threads

Top