Sample JACK client (sfizz_jack) goes into infinite loop on EOF
sfizz-1.2.3 compiled with gcc 11. If I start sfizz_jack and then hit ctrl-d to try to end the program, sfizz_jack instead goes into an infinite loop and I’ll have to hit ctrl-c to stop it.
Example (ctrl-d was pressed on line 54, i.e., immediately after I got a prompt):
[...]
42 Positional arguments: /opt/sfz/data/VCSL-1.2.2-RC/Chordophones/Zithers/Grand Piano, Kawai - Legacy.sfz,
43 Instrument loaded: /opt/sfz/data/VCSL-1.2.2-RC/Chordophones/Zithers/Grand Piano, Kawai - Legacy.sfz
44 ===========================
45 Total:
46 Masters: 0
47 Groups: 3
48 Regions: 126
49 Curves: 7
50 PreloadedSamples: 126
51 ===========================
52 Unknown opcodes:
53
54 >
55 >
56 >
57 >
58 >
[...]
11039 >
11040 >
11041 >
11042 >
11043 > ^C>
11044 >
11045 >
11046 > Signal received
11047 Closing...
Just tried this on current git version. Same behaviour and can also be reproduced by redirecting stdin from /dev/null.
CC @acli @redtide @KKQ-KKQ Any help with this? Makes it impossible to run as a background job (launching with " &", etc)
The REPL loop seems to be here if anyone knows how to fix it to properly detect EOF and exit: https://github.com/sfztools/sfizz/blob/806bf1dde49621d08c50a6a496b25c42b1afa8b8/clients/jack_client.cpp#L222
In the meantime, my workaround is to send it an empty string and newline once per minute like this:
( ( while true; do echo $'\n'; sleep 60; done ) | /home/pi/sfizz-ui/build/library/bin/sfizz_jack ...) &
@acli In my personal opinion, the client should not quit by Ctrl-D or EOF in order to run as a background job. ~Could you use a "quit" command instead? Or the client freezes?~ Oh I didn't try this actually because I am not a linux user. It enters the infinite loop.
@KKQ-KKQ I have a patch too (actually three; I tried a few different ways). It’s still open after one and a half months; I’m supposing they’re too busy.
@GeoffreyPlitt Fixing this will not (and should not) allow it to run as a demon. When it detects EOF the CLI thread ends and the program will (should) exit.
I think what you need is a flag to disable the CLI. I should be able to make you an unofficial patch but it’s been more than a month since I touched this. (My computer is too slow to do SFZ; I’ve sort of given up.)