[dev] [RFC] abduco: session {at,de}tach support

From: Marc André Tanner <mat_AT_brain-dump.org>
Date: Sat, 8 Mar 2014 20:29:38 +0100


I would like to get some feedback about abduco which provides session management
i.e. it allows programs to be run independently from their controlling terminal.
That is programs can be detached - run in the background - and then later

I hope the combination of abduco and dvtm will prove to be a simpler, cleaner
and generally suckless alternative to tmux or screen.


abduco is in many ways very similar to dtach but is actively maintained, contains
no legacy code, provides a few additional features, has a cleaner, more robust
implementation and is licensed under a BSD style license.

The command line interface is largely compatible with dtach, abduco thus can serve
as an almost drop in replacement.

What follows is a quick start guide, a new session is created with:

 abduco -c session-name command

if command is omitted it is implicitly set to dvtm. A session can be detached
with ^\ (CTRL+\). Executing abduco without any arguments prints a list of
active sessions. To restore a session attach to it via:

 abduco -a session-name

where session-name is the name which was used during session creation.

You might ask yourself why bother? What is wrong with dtach? As I wrote in
another email it all started more than a year ago when I had to do some
unix socket programming as part of an university exercise and thought I could
as well do something which might be useful. It then remained untouched until
a couple of days ago when I finally cleaned it up somewhat.

So what is wrong with dtach? What follows are a few things which abduco improves
upon dtach:

 - it is simpler (where it makes sense): for example it only supports
   1 redraw mechanism (based on SIGWINCH) instead of 3

 - it doesn't contain legacy code for broken systems whose bugs I don't understand

 - the exit status of the launched command is captured and printed once
   a client connects

 - it features a timeout mechanism which should disconnect misbehaving clients

 - sending SIGUSR1 to the server process recreates the unix domain socket
   which is used for the client / server communication

 - the resize policy when multiple clients are connected simultaneously is
   better. Resize requests are only processed if they are initiated by the
   the least recently connected client.

 - abduco is (or hopefully will be) more robust. There is still some research
   to be done which socket mode (SOCK_DGRAM, SOCK_SEQPACKET in combination with
   {recv,send}msg(2), or something else?) is best suited for reliable, message
   boundary preserving communication over a local unix domain socket.

   Comments from people who are familiar with the relevant POSIX spec and/or
   implementation details are more than welcome.

   The protocol currently in use is based on SOCK_STREAM and prefixes every
   message with a type and a length field.

As for a quick comparison with tmux. abduco like dtach does just reroute
I/O from the attached client to the underlying session. That is it doesn't
bother parsing any escape codes and thus doesn't preserve certain terminal
settings across session boundaries. This makes the code relatively simple
but has a few drawbacks in particular if you attach from different widely
"incompatible" sessions. I am not yet sure how bad it is in practice (certainly
not worse than dtach) but parts of it might be fixed by adding some
reinitialization code to dvtm.

Anyway I hope the combination abduco+dvtm is good enough and provides all
necessary features of tmux with about 1/7 of the SLOC.

Try it out and report back! As always patches welcome.

  git clone git://repo.or.cz/abduco.git

 Marc André Tanner >< http://www.brain-dump.org/ >< GPG key: CF7D56C0
Received on Sat Mar 08 2014 - 20:29:38 CET

This archive was generated by hypermail 2.3.0 : Sat Mar 08 2014 - 20:36:05 CET