I noticed a problem in one of my OpenBSD installation where tmux(1)
would lose its session socket after a few inactive days. Every time
that happened I quickly fixed it by sending a SIGUSR1 (as suggested by
the man page) to restore the socket session.

I also noted that would only happen on one machine which I had setup
one partition for /var/tmp and /tmp (and /tmp -> /var/tmp). After some
investigation I found out that the code that daily(8) uses to clean
/var/tmp is different from /tmp.

/tmp:
        Test if /tmp exists and it's not a symlink
                Clean all files unaccessed in 3 days except: ssh-*,
                    X11-unix, ICE-unix and portslocks
                Clean all directories unmodified in 3 days except: ssh-*,
                    vi.recover, X11-unix, ICE-unix and portslocks

/var/tmp:
        This one has similar rules as /tmp, but instead of cleaning all
        unaccessed files, it says: clean all not directories.

The following diff fixes the issue by ignoring folders belonging to
tmux(1) sessions. Another solution would be changing the find(1) type
flag to only remove files (and not 'not directories' which include
special files like sockets, pipe, devices etc...), but I found the
first one less intrusive and more correct.


Index: etc/daily
===================================================================
RCS file: /cvs/src/etc/daily,v
retrieving revision 1.80
diff -u -p -r1.80 daily
--- etc/daily   24 Apr 2014 19:04:54 -0000      1.80
+++ etc/daily   1 Jul 2014 00:49:54 -0000
@@ -49,7 +49,7 @@ if [ -d /tmp -a ! -L /tmp ]; then
        cd /tmp && {
        find -x . \
            \( -path './ssh-*' -o -path ./.X11-unix -o -path ./.ICE-unix \
-               -o -path ./portslocks \) \
+               -o -path ./portslocks -o -path './tmux-*' \) \
            -prune -o -type f -atime +3 -execdir rm -f -- {} \; 2>/dev/null
        find -x . -type d -mtime +1 ! -path ./vi.recover ! -path ./.X11-unix \
            ! -path ./.ICE-unix ! -path ./portslocks ! -name . \
@@ -60,7 +60,7 @@ if [ -d /var/tmp -a ! -L /var/tmp ]; the
        cd /var/tmp && {
        find -x . \
            \( -path './ssh-*' -o -path ./.X11-unix -o -path ./.ICE-unix \
-               -o -path ./portslocks \) \
+               -o -path ./portslocks -o -path './tmux-*' \) \
            -prune -o ! -type d -atime +7 -execdir rm -f -- {} \; 2>/dev/null
        find -x . -type d -mtime +1 ! -path ./vi.recover ! -path ./.X11-unix \
            ! -path ./.ICE-unix ! -path ./portslocks ! -name . \

Reply via email to