1

I have a process which reads and writes to a pseudo terminal. I would like to open xterm and have it open a pseudo terminal and leave it open so I can communicate with this process without creating yet another process.

Right now I use the following hack. I create a trivial program:

void main() {while(1);}

and then I open it in an xterm window like this:

xterm ~/a.out

Then I can write to the other process and read its output on the xterm window. Is there any way I can do this without having xterm spawn some useless process?

Edit: The process I am trying to communicate with is an operating system which is running inside the Bochs emulator. I am trying to connect the serial port on the emulated system with a pseudo terminal on the host system. I specify the particular pseudo terminal in the Bochs configuration file like this:

com1: enabled=1, mode=term,dev=/dev/pts/4
1
  • I'm confused: what is preventing you from using xterm your_app, so that the application has the pseudo terminal bound to its stdin/out/err?
    – peterph
    Feb 6, 2013 at 15:40

1 Answer 1

1

I'm afraid you can't - it is actually the way recommended in the bochsrc man page. If you are worried about the extra process, you can spawn this instead of your trivial loop:

#include <stdio.h>
#include <unistd.h>

int main(void)
{
    printf("tty:  %s\n", ttyname(0));
    while (1)
        sleep(60);
    return 0;
}

You'll get the tty name and the sleep() ensures that you don't waste precious SPU time in a trivial busy loop. You could also use pause() instead of sleep().

Or you can patch Xterm, it's open-source after all.

2
  • Thanks. I'm a little surprised it's not possible. I don't really have to use xterm. If there is another terminal emulator that will do this, that would work too.
    – user31765
    Feb 6, 2013 at 17:25
  • You can try other terminals, but I'd be a bit sceptical - running programs inside of them is the main raison d'être of terminals. :)
    – peterph
    Feb 6, 2013 at 19:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .