You are not logged in.

#1 2022-09-18 20:49:15

N_BaH
Member
Registered: 2015-12-30
Posts: 77

[solved] sox causes "Resource temporarily unavailable"

hi,

i usually run a script that woks well, but not today.

here is what it mainly does :

/usr/bin/sox ~/anySong.wav -d #aka play ~/anySong.wav
read yesNo

which outputs :

bash: read: read error: 0: Resource temporarily unavailable

i can reproduce that behaviour in a terminal by typing these commands in a one liner command.

have you got any idea ?

PS:
system is up to date.
bash version is

GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)

and sox is

SoX v14.4.2

Last edited by N_BaH (2022-09-19 19:32:03)

Offline

#2 2022-09-18 22:02:43

seth
Member
Registered: 2012-09-03
Posts: 31,898

Re: [solved] sox causes "Resource temporarily unavailable"

Is the sox call crucial??
It would see something leave the stdin in O_NONBLOCK, but I can't locally reproduce this w/ sox.
Did you try this in a clean™ shell (just openend, no other programs ran)?

https://stackoverflow.com/questions/198 … navailable at the bottom has a perl and python script to set the stdin back to blocking.

Offline

#3 2022-09-18 22:05:41

lmn
Member
Registered: 2021-05-09
Posts: 61

Re: [solved] sox causes "Resource temporarily unavailable"

This sounds like sox might keep stdin open. Have you tried to close it with 'sox --options <&-'.The relevant doumentation can be found here.

Also sox has been updated in the last couple of days, maybe that is related.

Edit: the MWE is indeed minimal

Last edited by lmn (2022-09-18 22:13:40)

Offline

#4 2022-09-19 19:31:24

N_BaH
Member
Registered: 2015-12-30
Posts: 77

Re: [solved] sox causes "Resource temporarily unavailable"

seth wrote:

is the sox crucial ?

what else could I use to record/read ogg files ?

seth wrote:

Did you try this in a clean™ shell (just openend, no other programs ran)?

yes, new and different Xterms (xterm, urxvt), and "dry" terminal (ttyN) too.

lmn wrote:

Have you tried to close it with 'sox --options <&-'.

using this trick makes the script run well, now. thank you.

Offline

#5 2022-09-19 19:54:12

seth
Member
Registered: 2012-09-03
Posts: 31,898

Re: [solved] sox causes "Resource temporarily unavailable"

what else could I use to record/read ogg files ?

What I meant was whether calling sox was crucial to trigger the problem.

Which version/build is it exactly?

pacman -Qi sox

Offline

#6 2022-09-19 23:16:21

N_BaH
Member
Registered: 2015-12-30
Posts: 77

Re: [solved] sox causes "Resource temporarily unavailable"

I didn't meet another program doing such a thing, yet.

$ pacman -Qi sox
Name            : sox
Version         : 14.4.2+r182+g42b3557e-1
Description     : The Swiss Army knife of sound processing tools
Architecture    : x86_64
URL             : http://sox.sourceforge.net/
Licenses        : GPL2  LGPL2.1
Groups          : None
Provides        : libsox.so=3-64
Depends On      : file  libid3tag  libltdl  libpng
Optional Deps   : alsa-lib: alsa plugin [installed]
                  flac: flac plugin [installed]
                  gsm: gsm plugin [installed]
                  lame: mp3 plugin [installed]
                  libao: ao plugin [installed]
                  libmad: mp3 plugin [installed]
                  libpulse: pulse plugin [installed]
                  libsndfile: caf, fap, mat4, mat5, paf, pvf, sd2, sndfile, w64 and xi plugins [installed]
                  libvorbis: vorbis plugin [installed]
                  opencore-amr: amr_nb and amr_wb plugins [installed]
                  opusfile: opus plugin
                  twolame: mp3 plugin [installed]
                  wavpack: wavpack plugin [installed]
Required By     : None
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 1310.18 KiB
Packager        : Jan Alexander Steffens (heftig) <heftig@archlinux.org>
Build Date      : Thu Sep 15 01:08:34 2022
Install Date    : Sun Sep 18 02:15:05 2022
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : SHA-256 Sum

Offline

#7 2022-09-20 06:32:26

seth
Member
Registered: 2012-09-03
Posts: 31,898

Re: [solved] sox causes "Resource temporarily unavailable"

Ah, it's important to run the commands in a row because the prompt (apparently) sanitizes stdin.
And strace shows that sox indeed runs "fcntl(0, F_SETFL, O_RDWR|O_APPEND|O_NONBLOCK|O_LARGEFILE)" but not anything to suggest it would clean up afterwards.

=> That's a bug, https://sourceforge.net/p/sox/bugs/
(The workaround won't work if one wants to pipe something into sox)

Edit: https://sourceforge.net/p/sox/bugs/273/ … apparently has been a problem in the past.

Last edited by seth (2022-09-20 06:33:47)

Offline

Board footer

Powered by FluxBB