1
0
Fork 0
mirror of https://codeberg.org/noisytoot/notnotdnethack.git synced 2025-04-06 08:30:41 +01:00

Fix playing sounds sometimes interfering with prompts

The signal handler was interrupting read().  Register it with
SA_RESTART so it doesn't interrupt syscalls.

Also close stdin/stdout just in case (portaudio only uses stderr).
This commit is contained in:
Ron Nazarov 2024-05-07 21:58:58 +01:00
parent 11ca7cd6e2
commit a1db2bb9b8
Signed by: noisytoot
GPG key ID: 1D43EF4F4492268B

View file

@ -130,7 +130,7 @@ play_usersound(const char *filename, int volume)
kill(nowplayingpid, SIGTERM);
/* Register signal handler */
struct sigaction handler = {
.sa_flags = SA_SIGINFO,
.sa_flags = SA_SIGINFO|SA_RESTART,
.sa_sigaction = usersound_sigchld_handler
};
sigaction(SIGCHLD, &handler, &orig_handler);
@ -147,7 +147,9 @@ play_usersound(const char *filename, int volume)
signal(SIGINT, SIG_DFL);
signal(SIGHUP, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
/* portaudio prints junk to stderr, close it so it doesn't mess up the display */
/* Close stdin/stdout/stderr so it doesn't mess up the display */
fclose(stdin);
fclose(stdout);
fclose(stderr);
/* Finally, play sound and exit */
play_usersound_blocking(filename, volume);