Re: Help with pipes, buffering and pseudoterminals

2015-04-07 Thread Gregory Ewing
Chris Angelico wrote: Really? I can believe that stdout and stderr are initially duplicates, but stdin as well? Isn't stdin opened for reading only, and stdout/stderr for writing only? It depends entirely on how the process that forked your shell process set things up, but a quick experiment I

Re: Help with pipes, buffering and pseudoterminals

2015-04-07 Thread Ian Kelly
On Tue, Apr 7, 2015 at 4:06 PM, Cameron Simpson wrote: > On 07Apr2015 20:38, Chris Angelico wrote: >> >> On Tue, Apr 7, 2015 at 3:48 PM, Cameron Simpson wrote: >>> >>> The operating system arranges the commection of the shell to the >>> terminal. >>> Your usual program has by default a stdin, st

Re: Help with pipes, buffering and pseudoterminals

2015-04-07 Thread Cameron Simpson
On 07Apr2015 20:38, Chris Angelico wrote: On Tue, Apr 7, 2015 at 3:48 PM, Cameron Simpson wrote: The operating system arranges the commection of the shell to the terminal. Your usual program has by default a stdin, stdout and stderr. These are _all_ the same file handle, duplicated to each of

Re: Help with pipes, buffering and pseudoterminals

2015-04-07 Thread Chris Angelico
On Tue, Apr 7, 2015 at 3:48 PM, Cameron Simpson wrote: > The operating system arranges the commection of the shell to the terminal. > Your usual program has by default a stdin, stdout and stderr. These are > _all_ the same file handle, duplicated to each of the three file descriptors > 0, 1 and 2

Re: Help with pipes, buffering and pseudoterminals

2015-04-06 Thread Cameron Simpson
On 06Apr2015 21:13, Daniel Ellis wrote: Wow, thank you for the long and detailed reply. As for the question ptys and C, no, I have no experience in that area. No worries. The use is the same in Python. BTW, you may want a fixed width font; there are some ASCII diagrams in this message. I

Re: Help with pipes, buffering and pseudoterminals

2015-04-06 Thread Daniel Ellis
Wow, thank you for the long and detailed reply. As for the question ptys and C, no, I have no experience in that area. I've read a bit on the master/slave stuff, but I'm still finding it confusing. The manpage for pty states that it creates a "pair" of virtual devices, one master and one slave.

Re: Help with pipes, buffering and pseudoterminals

2015-04-05 Thread Cameron Simpson
On 05Apr2015 12:20, Daniel Ellis wrote: I have a small little tool I'd like to make. It essentially takes piped input, modifies the text in some way, and immediately prints the output. The problem I'm having is that any output I pipe to the program seems to be buffered, removing the desired

Re: Help with pipes, buffering and pseudoterminals

2015-04-05 Thread Nobody
On Sun, 05 Apr 2015 12:20:48 -0700, Daniel Ellis wrote: > This only seems to print from the parent process. I read that I need to > do the os.read call for the fork to happen. I've also tried printing > *after* the os.read call. The child process has its std{in,out,err} attached to the newly-cr

Help with pipes, buffering and pseudoterminals

2015-04-05 Thread Daniel Ellis
I have a small little tool I'd like to make. It essentially takes piped input, modifies the text in some way, and immediately prints the output. The problem I'm having is that any output I pipe to the program seems to be buffered, removing the desired effect. >From what I understand, I need t