johnath / beep

beep is a command line tool for linux that beeps the PC speaker
http://www.johnath.com/beep/
GNU General Public License v2.0
186 stars 49 forks source link

beep fails, but exits 0 (unless strace'd) #8

Open jzacsh opened 8 years ago

jzacsh commented 8 years ago

Not sure how to debug this yet, so I'm just providing some info that I'm guessing is at least bug worthy: the exit status should be non-zero, I believe (as you can see errors occur, via strace)

beep itself:

$ beep -v
beep-1.3
$ beep # exits 0, no sound

straced, changes exit status:

$ strace beep # exits 1, no sound
execve("/usr/bin/beep", ["beep"], [/* 85 vars */]) = 0
brk(NULL)                               = 0xa81000
fcntl(0, F_GETFD)                       = 0
fcntl(1, F_GETFD)                       = 0
fcntl(2, F_GETFD)                       = 0
access("/etc/suid-debug", F_OK)         = -1 ENOENT (No such file or directory)
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f32e0bad000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=120136, ...}) = 0
mmap(NULL, 120136, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f32e0b8f000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\10\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1697504, ...}) = 0
mmap(NULL, 3803552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f32e05eb000
mprotect(0x7f32e0782000, 2097152, PROT_NONE) = 0
mmap(0x7f32e0982000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x197000) = 0x7f32e0982000
mmap(0x7f32e0988000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f32e0988000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f32e0b8e000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f32e0b8d000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f32e0b8c000
arch_prctl(ARCH_SET_FS, 0x7f32e0b8d700) = 0
mprotect(0x7f32e0982000, 16384, PROT_READ) = 0
mprotect(0x7f32e0baf000, 4096, PROT_READ) = 0
munmap(0x7f32e0b8f000, 120136)          = 0
brk(NULL)                               = 0xa81000
brk(0xaa2000)                           = 0xaa2000
rt_sigaction(SIGINT, {0x400f60, [INT], SA_RESTORER|SA_RESTART, 0x7f32e061e250}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGTERM, {0x400f60, [TERM], SA_RESTORER|SA_RESTART, 0x7f32e061e250}, {SIG_DFL, [], 0}, 8) = 0
open("/dev/tty0", O_WRONLY)             = -1 EACCES (Permission denied)
open("/dev/vc/0", O_WRONLY)             = -1 ENOENT (No such file or directory)
write(2, "Could not open /dev/tty0 or /dev"..., 50Could not open /dev/tty0 or /dev/vc/0 for writing
) = 50
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 4), ...}) = 0
write(2, "open: No such file or directory\n", 32open: No such file or directory
) = 32
write(1, "\7", 1)                       = 1
exit_group(1)                           = ?
+++ exited with 1 +++

Some more info, in case it's helpful:

$ echo -e '\a' # no sound

$ mpv /usr/share/sounds/freedesktop/stereo/bell.oga # SOUND! bell dings
Playing: /usr/share/sounds/freedesktop/stereo/bell.oga
 (+) Audio --aid=1 (vorbis)
AO: [pulse] 44100Hz stereo 2ch float

Exiting... (End of file)
penn5 commented 6 years ago

Afair you can't debug/strace a setuid as non-root

ndim commented 5 years ago

Do not run beep as setuid-root or via sudo-root. See #11 for details.

In January 2019, I have changed beep to prioritize the new speaker API which does not require setuid-root or sudo-root, fixed the bugs from #11 and others, and published the updated code on https://github.com/spkr-beep/beep where release 1.4.4 is current. A number of distributions are using the new code base at this time: Arch Linux, Debian unstable, Fedora 28 and later, Ubuntu whatever-is-tracking-Debian-unstable.

Please update to beep-1.4 or later, and if the problem persists, you can run a proper strace and report your issue over at https://github.com/spkr-beep/beep/issues so I can take a look.

Your problem might just be the hardware audio mixer input for the PC speaker (going to your laptop speakers) being turned to 0.