4 I just got so tired of being limited to printf("\a"); when I wanted a terminal
5 beep. This program isn't supposed to be anything stupendous, it's just
6 supposed to get the job done. Its intended purpose in life is to live inside
7 shell/perl scripts, and allow a little more granularity than you get with the
8 default terminal bell. Maybe I'm the only one who thinks this is useful. :)
10 If for any reason you decide you need to, contact me:
15 And beep can generally be found at:
17 http://johnath.com/beep/
19 For installation instructions, see INSTALL.
20 For copying and (non-)warranty information, see COPYING.
21 For usage information, check the man page.
23 There is a github repository of this code at: git://github.com/johnath/beep.git
28 As noted in the man page, some users are running into a situation where beep
29 dies with a complaint from ioctl(). The reason for this, as Peter Tirsek was
30 nice enough to point out to me, stems from how the kernel handles beep's
31 attempt to poke at (for non-programmers: ioctl is a sort of catch-all function
32 that lets you poke at things that have no other predefined poking-at mechanism)
33 the tty, which is how it beeps. The short story is, the kernel checks that
36 - you are the superuser
37 - you own the current tty
39 What this means is that root can always make beep work (to the best of my
40 knowledge!), and that any local user can make beep work, BUT a non-root remote
41 user cannot use beep in it's natural state. What's worse, an xterm, or other
42 x-session counts, as far as the kernel is concerned, as 'remote', so beep
43 won't work from a non-priviledged xterm either. I had originally chalked this
44 up to a bug, but there's actually nothing I can do about it, and it really is
45 a Good Thing that the kernel does things this way. There is also a solution.
47 By default beep is not installed with the suid bit set, because that would
48 just be zany. On the other hand, if you do make it suid root, all your
49 problems with beep bailing on ioctl calls will magically vanish, which is
50 pleasant, and the only reason not to is that any suid program is a potential
51 security hole. Conveniently, beep is very short, so auditing it is pretty
54 Decide for yourself, of course, but it looks safe to me - there's only one
55 buffer and fgets doesn't let it overflow, there's only one file opening, and
56 while there is a potential race condition there, it's with /dev/console. If
57 someone can exploit this race by replacing /dev/console, you've got bigger
60 So the quick solution is beep is not beeping when you want it to is:
64 # chmod 4755 /usr/bin/beep
66 (or wherever you put it)
68 The one snag is that this will give any little nitwit the ability to run beep
69 successfully - make sure this is what you want. If it isn't, a slightly more
70 complex fix would be something like:
72 # chgrp beep /usr/bin/beep
73 # chmod 4750 /usr/bin/beep
75 and then add only beep-worthy users to the 'beep' group.
80 A surprising number of people have sent in requests, or even patches, to help
81 beep play multiple, different sounds off a single invocation. I had always
82 thought that if people wanted a more complex melody, they would just do
85 $ cat << EOF > song.sh
87 beep <first beep's options>
88 beep <second beep's options>
92 Nevertheless, because of repeated and vociferous demand, version 1.2 (and
93 presumably all later versions) include the -n/--new switch which allows you to
94 use one command line to create multiple beeps. Check the man page for
95 details. I have also had a couple people suggest that I encourage the
96 development of such shell scripts/command lines, even collect the particularly
97 melodious ones. Certainly if anyone feels like sending some to me, I will put
98 them somewhere visible, or even include them as a sample. I think Dvorak's New
99 World Symphony, 4th Movement, for example, would make a lovely shell script.
100 I also wouldn't mind a rendition of BNL's If I had a million dollars. But by
101 all means, be creative.
103 All files copyright (C) Johnathan Nightingale, 2002.
104 All files distributed under the GNU general public license.