2

1) I want to open a terminal for input/output of different processes that are already running. When I open a new terminal, bash is automatically executed and I can't get the terminal stdin, as it is already taken by bash. I want to run a terminal window, with no executables linked to it.

2) If I'm connecting through SSH, how could I get the same behavior for a new connection? i.e. having a remote terminal with no bash running?

Running Ubuntu.

2 Answers 2

1

Open the terminal with a program that sits there doing nothing. You don't actually need to have any program running in a terminal, except that most terminal emulators run a program connected to the application side of the terminal when they start, and shut down the terminal when that program exits.

There's no command to do nothing forever until killed by a signal in the standard Unix tool suite, but sleep 999999999 comes close enough.

xterm -e sleep 999999999
ssh -tt host.example.com sleep 999999999

You may want to report the terminal device somewhere.

tty=$(xterm -e sh -c 'tty >&3; exec sleep 999999999' 3>&1)
3
  • You are right. I've edited your answer to have -t -t in the ssh command, as otherwise the tty is not created by default (at least in my system). Thank you!
    – AndresR
    Commented Dec 6, 2016 at 3:23
  • I believe my edit was rejected. ssh host.example.com sleep 999999999 should be ssh -t -t host.example.com sleep 999999999 otherwise the terminal is not created (at least in my system). I will accept the answer if you add that (or explain how it should work with the original command).
    – AndresR
    Commented Dec 6, 2016 at 5:43
  • I wrote and published a tool named pause that does exactly that, a call to sigpause/sigsuspend. (-:
    – JdeBP
    Commented Dec 6, 2016 at 6:43
0

Most processes if not associated with a terminal will have their stdin/stdout/stderr pointing somewhere else either on the file system or to /dev/null.

Not really sure what you're going after.

Attaching to other processes can be done with a debugger. You'd have to be a root user.

You could run a command like this to see where they point to:

 find /proc -name 0 -o -name 1 -o -name 2 | xargs ls -ld

If you simply want to be able to re-attach to programs you own and see their output, you can first start them from within a cool program called screen, which starts a session in which you can start multiple terminal windows and run your program, then if you get disconnected, and reattach to them later.

1
  • I'm sorry If the question was not clear enough. I just wanted to create a terminal with stdin and stdout not associated to any process, nothing related to the existing processes. I have control over those processes and I can redirect them later to the just created terminal. Thanks anyway.
    – AndresR
    Commented Dec 6, 2016 at 3:28

You must log in to answer this question.

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