Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
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 '13 at 15:40
up vote 1 down vote accepted

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)
    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.

share|improve this answer
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 '13 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 '13 at 19:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.