5
detachtty lets you run interactive programs non-interactively, and
6
connect to them over the network when you do need to interact with them.
8
If you've used screen, it's a similar concept. Compared to screen,
11
* no capability to swap between different screens (it doesn't co-opt C-a)
12
* no tty emulation (you can sanely use it in emacs comint modes)
13
* no features (less to go wrong)
14
* no configuration file
15
* ability to spawn ssh to securely connect across the network
17
* What it's for - a likely usage scenario
19
I have a persistent server implemented in Lisp. Usually it sits there
20
serving things, but sometimes (for example when a new version is
21
available and it needs to be upgraded) I need to connect to it and
24
Why don't I use screen? I could - I used to do exactly that - but
25
then I have to talk directly to the CMUCL repl, which means no command
26
line editing. I want to use ILISP, but (1) screen's terminal handling
27
is likely to confuse Emacs, (2) screen isn't network-enabled and the
28
server machine doesn't have Emacs installed anyway.
32
detachtty has two parts:
34
** detachtty - the server
36
opens a pseudoterminal and starts your program on the slave end. It
37
then copies between that tty and a unix-domain socket whose location
38
you specify when you start it
40
detachtty has options to fork into the background, to specify the
41
socket location, and to govern the placement of its log file and of
42
the dribble file from the application underneath it
44
** attachtty - the client
46
When you want to connect to the process, attachtty attaches to the
47
unix-domain socket and copies input/output to and from you.
49
If you have ssh installed and set up, you can also use attachtty
50
across the network. This requires
52
- that you also have attachtty installed on the machine that you are
53
running detachtty on, and that it's somewhere on the path
55
- that you have ssh set up not to need to ask for a password (e.g
58
It's often nice to be able to interrupt a process, especially when
59
it's stuck in some kind of loop. attachtty catches SIGINT and sends
60
the character \003 into the pty master, which causes the controlled
61
process to get a SIGINT of its own. This works at least for using
64
* Using it - an example
66
server$ detachtty --help
67
detachtty: unrecognized option `--help'
69
detachtty [--no-detach] [--dribble-file name] [--log-file name] \
70
[--pid-file name] socket-path command [arg] [arg] [arg] ...
72
server$ detachtty --dribble-file /var/log/cliki-dribble --log-file \
73
/var/log/detachtty.log --pid-file /var/run/cliki.pid \
74
/var/run/cliki-socket /usr/bin/lisp -eval '(load-system :telentweb)' \
75
-eval '(progn (telentweb::init) (telentweb::start))' \
77
client$ attachtty dan@server:/var/run/cliki-socket
79
** Signals and log files
81
When detachtty receives a SIGHUP, it closes and reopens its log and dribble
82
files, so it should play nice with whatever log rotation tools you already
83
use. Note that the dribble file especially can grow large quite quickly
85
The SIGHUP should be sent to detachtty, not to the child. What the child
86
does with signals depends entirely on what the child is ...
89
* Security considerations
91
- detachtty performs no authentication of who's attached. You choose
92
where the socket is created in the filesystem, so choose somewhere
93
that other people can't get to.
95
(detachtty creates its socket with mode 0700. Some Unix systems -
96
Linux among them - honour file permissions on sockets, so only the
97
original user or root will be able to connect to it. However, "many
98
BSD derived systems [...] ignore permissions for Unix sockets" so you
99
need to check if this will help you or not.)
101
- communication across the net is done using ssh. If there is a
102
program on your computer called "ssh", then whatever level of security
103
it provides is available here
105
- no serious effort has been made to examine the attachtty and
106
detachtty code for buffer overruns etc. If you are planning on using
107
these setuid or in some other untrusted-user situation, now is the
108
time to think of an alternative plan.
113
detachtty is part of the Debian GNU/Linux system. Debian "woody" and
114
"sid" users should find that "apt-get install detachtty" will download
115
and install it for them.
117
Users of other platforms are invited to check the CLiki page at
118
<URL:http://ww.telent.net/cliki/detachtty> which should always contain
119
a link to a download location.
122
* Feedback, feature requests, patches
124
to dan@telent.net, or using the Debian bug tracking system (bug reports
125
can be sent to the BTS even if you're not using Debian; it's exactly
126
the same package either way), or leave a note on the CLiki page