1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
|
---------------------------------------------------
spinner 1.2 by Joe Laffey, LAFFEY Computer Imaging.
---------------------------------------------------
Doc: $Revision: 1.5 $
Visit http://www.laffeycomputer.com/ for updates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-------------
WHAT IS IT?
-------------
Spinner is an anti-idle program that displays a little "spinning" ASCII
character in the top left corner of your terminal. To make this effect it
cycles through punctuation marks like this " - \ | / - \ | / ... " (try it to
see). By default the character is drawn in inverse video (or your terminal's
equivalent). But you can turn this off with the -i switch. In spinner mode
Spinner supports any terminal capable of handling VT100 style escape codes. In
null mode (-n switch) Spinner supports any terminal. In null mode there is no
visible output, and Spinner will not interfere with your terminal or
scrollback. If you find the little spinner in the top left corner to be
distracting use null mode. (-n switch).
Spinner is useful for keeping telnet and ssh links from dropping due to
inactivity. Many firewalls, and some ISPs drop connections when they are
perceived as idle. By having spinner running the server is constantly
sending a tiny amount of data over the link, preserving the connection. As of
version 1.2 Spinner can also be activated with the -n switch so that, instead
of displaying a spinner, it simply sends out a periodic null character to the
terminal. This achieves the same anti-idle benefit without disturbing your
screen. But it lacks the coolness factor of a little spinner in the corner
of the terminal...
Thus (for search engines) Spinner is an anti-idle, timeout preventing,
background daemon process for unix variants including linux. Spinner is
known to compile and work properly under NetBSD 1.5 and 1.6, Mac OS X 10.2,
linux 2.2 and 2.4.
Spinner also has a (mainly fun) mode I like to call "Ghost in the Machine"
mode. In this mode you can use spinner to write the spinner character to
ANY tty, not just your own. This requires adequate permissions, of course.
(see below)
-----------------
HOW DO I USE IT?
-----------------
Basic summary: (spinner -h)
Usage: spinner[-IntTuvl<path>[f<path>|F][p<prio>|P]] [delay]
-f <path> Set pid file path (default is ~/.spinner.pid)
-F Do *not* create a pid file
-I Do *not* use inverse video for spinner
-l <path> Set log file path (for debugging). Off by default.
-L Display the license
-n Send only null characters. (No visible output.)
-p <priority> Specify process priority to use
-P Do *not* change process priority (default is to make nice)
-r Reset term on quit (Use if you get left in inverse a lot.)
-R Reset the term and Quit immediately. (nothing else)
-t <tty path> Specify path of TTY to which to write
-T Ignore incompatible TERM environment var setting
-u Delay is in microseconds instead of seconds
-v Verbose mode (lots of output)
Returns: 0 on success, non-zero on failure.
Launches into the background on success.
Use: kill `cat <pidfile>` to stop.
----------------
IMPORTANT INFO <--read this
----------------
* IN ORDER FOR SPINNER TO PREVENT IDLE CONNECTIONS YOU MUST RUN IT ON THE
SERVER. If you run Spinner on your client the data is not sent over the
wire. It is only drawn locally. So you must run Spinner on the remote
machine to keep the data coming to your terminal over the wire. If you do
not have root access on the remote machine you can still use Spinner.
Compile Spinner with "./configure --prefix=</your/bin/dir> && make install".
You can then launch Spinner from your .login file or .tcshrc / .profile
file if you wish.
* Spinner is a daemon process (also known as a background process). When
you start spinner it will launch into the background as not to interfere
much with your foreground jobs. By default Spinner creates a pid (process
id) file called ".spinner.pid" in your home directory. (You may use the -f
or -F switches to modify this behavior.) Note this pid file has a "."
character in front so you will need to use ls -a to see it in a listing.
You can use this file to easily kill Spinner with the command:
kill `cat ~/.spinner.pid`
Note that those are backticks (top left key below ESC, same key with ~).
Of course you can also just find Spinner in your process list and kill
it manually that way. Spinner's pid file is NOT a lock file. It will be
overwritten every time you launch a copy of Spinner. So if you have
multiple spinners running you will have to kill them manually.
Spinner should commit suicide (i.e. quit) if the tty to which it is
writing is no longer active. Sometimes, if you start Spinner writing
to another tty when that tty is not active to begin with Spinner will
not quit. (Anyone know why?? Tell me.)
* Since Spinner draws to the terminal it is possible (and likely) that
the spinner character will end up in the terminal's scrollback. To
reduce this annoyance you can use a long delay. As of version 1.2 you may
opt to use the -n switch to cause spinner to send only null characters,
instead of the spinning cursor. If you do not use -n you may also kill
Spinner with the STOP signal (kill -STOP `cat ~/.spinner.pid`) and
then continue it after you get your scrollback via the CONT signal
(kill -CONT `cat ~/.spinner.pid`).
* Spinner may interfere with the display of mouse selections. If you drag
out a selection the highlighted text may become unhighlighted as sooner
as Spinner draws to the terminal. Typically the contents of the paste
buffer still remain, however. So even though you lose the highlighting
you can still paste the text that you selected in the usual fashion.
Again, as of version 1.2 you may opt to use the -n switch to cause
Spinner to only send null characters to the screen (which do not show up).
* At startup spinner checks to be sure your TERM environment variable
is set to "vt100" or "vt102". It only checks for these since these are
the only terminal types that I KNOW will accept the vt100 escape codes
(to move the cursor, inverse video, etc.) Spinner works perfectly
well in every terminal I have tried it in (including GNU screen, eterm,
xterm, aterm, etc.) If you get the message about your terminal not
being "vt100" or "vt102" simply invoke Spinner with the -T switch. This
forces Spinner to ignore the TERM setting. Note that if you use spinner
on a dumb terminal, or any other terminal that does not support the
escape codes you will see a lot garbage characters. Just stop Spinner
and get a real terminal! If you find this check annoying, or think
it should go away let me know. Note that if you use the -n switch Spinner
will not check the terminal type at all, as it is not attempting to move
the cursor, change inverse modes, etc.
* Note that if you would like to use Spinner in conjunction with the GNU
screen program (one of the world's coolest programs, screen is a
"terminal multiplexer" allowing multiple virtual terminals in a single
terminal window, switching between them, detaching and resuming screens
both local and remote, etc.) you will want to start Spinner *BEFORE* you
start screen. Otherwise Spinner will end up in one of screen's virtual
terminals, which means that it may not be on the real terminal all the
time. This could lead to an idle timeout, which is exactly what Spinner
was coded to prevent. You may also be able to determine your parent
tty (the original tty from which you invoked screen), and have Spinner
write to that tty using the -t switch. (This would let you invoke
Spinner in such a way that it would write to the parent terminal even
though you launched Spinner from within screen.
* In normal operation (delay >= 2 sec) Spinner functions well with most
terminals / emulators. However, if you switch to microsecond mode for
the delay (-u) and use lower delays it is possible that your terminal
will become somewhat garbled. You will notice that parts of the screen
that shouldn't be are displayed in inverse text, or text is in the wrong
place, etc. Setting a higher delay will normally make this issue
non-existent. Note that "Terminal.app" under Mac OSX seems more prone to
do this. Gnome term and eterm, etc seem immune. **NOTE: In version 1.2
the code was reworked to all but eliminate this. If you encounter this
issue, please send me an email with your system info. Since
when using the -n switch Spinner does not send printable characters you will
not experience this problem at all.
* If you use an extremely low delay on a slow link, or use a slow-drawing
terminal, be prepared for Spinner to slow your terminal down. I would say,
"Don't do that!" Spinner is coded to be very efficient in its main loop.
Only one write statement and one check to be sure the tty is active per
iteration. Since Spinner is meant as an anti-idle tool you will most
likely keep the delay high (but less than 30 sec or so depending upon
what it is that is timing out your connection to begin with).
* By default Spinner will set its process priority (niceness) to 10. You
can use the -p or -P switches to modify this behavior.
* Sometimes when you terminate Spinner it could leave the terminal in a
state you were not expecting (e.g. inverse video "stuck" on, cursor in
the wrong spot, etc.) If you experience this a lot consider the -r switch.
This will send a vt100 reset code at quit, which usually helps, but will
clear your terminal screen. **NOTE: In version 1.2 the code was reworked
to all but eliminate this. If you encounter this issue, please send me an
email with your system info.
If your terminal gets stuck in an inconsistent (read "whacked") state you
can try to fix it by running Spinner with the -R switch. With this switch
ALL Spinner will do is sen a vt100 reset code to the tty (then quit).
Using the -n switch will avoid these problem altogether by sending only
null characters to the terminal. You loose the cool little spinner effect,
however.
* Verbose mode will walk you through most of the steps Spinner takes as it
launches. Mainly for debugging, it can, however, help you troubleshoot
switch settings. Note that once Spinner has forked to the background it
no longer has a controlling terminal and cannot output error messages.
In or to see verbose output (or errors) after the fork you must use the
-l switch and specify a filename to write to. This file will ONLY
contain the output from Spinner AFTER the fork. Most likely you will
never need this, but it is available if you do. Note that it t is
perfectly normal to see a no such file or directory error in this log when
logging out of linux. Linux cretaes and deletes files in /dev/pts/ with
every change of TTY.
* Ghost in the Machine mode (i.e. using the -t switch to write to another
tty other than your controlling terminal) can be both fun and (a little)
useful. To use this mode determine the PATH to the tty you want Spinner
to write. Usually the "tty" command will display your own terminal. This
should give you the basic path/filename structure (usually "/dev/ttypXX"
where "XX" is a number). Then do a "who" command to see which particular
tty you want to write to. This will show you a list of logged in users
and their ttys. Next run spinner with the -t switch and specify the path
to the desired tty. Note that you must have permission to write to the
desired tty. Ttys are setup to be owned by the user logged into them, and
usually setup with a group of "tty". So you can always write to any of
your own ttys. To write to someone else's tty you either need to be root,
or root needs to setup Spinner as setgid (not setuid) "tty". There are
security concerns with any setuid or setgid program. So don't be
surprised if your administrator says no. Spinner has not been thoroughly
audited for security. Though little could go wrong, small seemingly
meaningless things can lead to real big security holes. You've been
warned. Spinner is NOT installed setgid (or setuid) by using the
"make install" command. Spinner will not run if it is made setuid.
-------------
TO DO
-------------
Allowing the user to specify the position of the spinning character
might be fun, and somewhat useful.
Perhaps putting the spinner into a banner at the top or bottom of the
screen (like GNU screen's dividers) would be useful, as they spinner
would not encroach into the active terminal area (the virtual terminal
would be made smaller)
Adding a spinner to the existing banner in the GNU screen program would
be very useful for those who use screen.
Calls to signal() should be replaced with sigaction() stuff.
Any way to prevent scrollback of the spinner character instead of valid
data would be useful (such as the banner at the bottom previously
mentioned).
Perhaps a switch to kill running Spinner(s) instead of using the kill
command might be useful for novice users. However, novice users are
unlikely to be using Spinner to begin with...
-------------------------------
Who Made This Thing? (and Why?)
-------------------------------
Original code:
Joe Laffey <software@laffeycomputer.com>
I made it to keep alive ssh connections that were being timed out by
my firewalls. Plus it looks cool, and was a nice experiment in
writing directly to ttys.
Beta Testers:
Jonathan Dickmann <bob@bobarmadillo.com>
Michael Hostbaek <mich@freebsdcluster.org>
Patrick Norman <saitan@packetmonkeys.com>
Evlampy Oduvanchikoff <necro@netbastards.org>
Ed Okerson <eokerson@texasconnect.net>
Thank You!
|