-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SIGTSTP keeps the speaker active #31
Comments
Thank you very much for the report! This is awesome. Such an old program, and the first time this comes up is in 2022. First, to turn off the speaker, you can just run Second, as to what the "proper" behaviour should be for Again, thank you! |
Ya no problem. Is there a newer preferred way to control the PC speaker then? When I looked up how to control the speaker, beep was one of the top results. When I installed it, I was at a loss as to why it didn't just play the tone as a non root user, so I tried with sudo and it said it wouldn't run as root for security reasons. This led me to find I had to add a udev rule and presto it works but I don't understand why the package manager doesn't create the udev rule when installing the program. I also saw that some distros are disabling the pcspkr module which will make it harder for new users if they find a guide that doesn't say they need to run sudo modprobe pcspkr. |
One possible behaviour for when I will address your other remarks and questions later. |
How to control the speaker: Well, the PC speaker has been on its way out for the last 20 years. Laptops have a proper sound system to which the PC speaker output may or may not be routed, and desktop PCs often come without the speaker or buzzer connected to the connectors on the PC motherboard. For many years, notification noises usually go through the PCM sound output (think error notification dialogs popping up, or terminals beeping on backspace in an empty line). So the industry appears to have stopped caring for the PC speaker, except maybe for pre-boot or firmware early boot problems which can be signalled by a speaker connected to the motherboard. So not much work has been put into software support either. Linux has its API (turn it on with frequency X, turn it off) in two reincarnations (I call them console and evdev), FreeBSD has its API (play frequency X for duration Y, so the kernel maintains some state), and I have no idea about API on Windows PCs or about hardware support and API on Macs. On Linux, As to how to install If you need to build and install If you use a Linux distribution's However, even the Fedora For some time, the Debian package decided to not set up the So different distributions' If someone has an idea to simplify this mess, both on the |
So it appears there is SIGSTOP and SIGTSTP which stop a process, and SIGCONT lets them continue. It appears I can install handlers for all three, but So both SIGSTOP and SIGTSTP should silence the PC speaker, and SIGCONT should re-enable the PC speaker. The state machine for that must handle repeated signals, e.g. many SIGCONT signals arriving without stop signal in between. I need to do some experiments with code there, and some hard thinking about security and robustness, the latter maybe including some outside expertise. And the whole thing might be easier if |
Wow thanks for the detailed response and maintaining this program. |
Where do I have to look to keep programs from using beep? I only want it to use it in my scripts and to play with but Firefox makes it beep when using the "Find in page" bar and Edit: I don't know of a way to reenable that once it is disabled though. |
Desktop programs like They use some desktop environment interface, and that eventually generates something audible, and that audible thing is very probably not the PC speaker hardware (which The details vary depending on your application and desktop environment. |
In my desktop environment (Gnome 43 RC on Fedora 37 Beta), Anyway, |
It is the buzzer, it happens while my speakers are off and not until after I added the evdev rule. I tried, Edit: it's xset -b or xset b off to turn off but only xset b on to turn on. |
A quick stop gap measure could be installing the following noop signal handler for
However, this changes the program behaviour not only regarding whether the sound continues while the
I fear to implement this properly, the main loop must be completely rewritten from scratch as a proper event loop running a state machine which can react to the proper signals and other events, especially on SIGTSTP turning off the speaker and after SIGCONT turning the speaker back on and continue the interrupted waiting period.
|
It appears that So |
Why can't the time in nanoseconds be read from the real time clock when beep is run and then read again in the event loop? That plus the |
Hmm. Maybe. Of course there are event loop libraries which offer timer sources, but I do not know how they do it and I also do not want beep to have essential (and possibly big) build dependencies beyond a C compiler, a libc, and a Linux kernel. |
Well you can always statically link. How large are these libraries? |
Some libraries implementing event loops for C code which I could find quickly:
Anyway, I do not want to link against any of these. At most, I want to find out from them how to best implement a timer in a way suitable for beep. |
Quick note for later: Hooking |
I would think that SIGTSTP shown as ^Z should pause a long tone from playing and start playing again when fg is entered. And if not that then just halt the process the same as SIGINT - ^C.
Or is there a reason that it's this way that I am missing?
I ask because I just pressed Ctrl + Z by accident and couldn't stop the speaker. I had to run sudo rmmod pcspkr so I wouldn't have to listen to it while I looked up how to reverse a SIGSTP for if I did that again.
The text was updated successfully, but these errors were encountered: