Bash – Why do ‘nohup’ and ‘disown’ not work on SoX (invoked as ‘play’)

bashdisownnohupsox

I can run this command:

$ play mylist.m3u

And music plays.

I can then press Ctrl-Z to suspend the job, and issue bg to have it run in the background.

However, if I then run disown and exit, the music stops playing, even though the play command still shows up in ps.

I would expect the music to keep playing.

Also interesting

I run the command

$ play mylist.m3u &

Music does not play. The job shows as the stopped status.

I can also run the command

$ nohup play mylist.m3u &

And no music plays – the job immediately stops.

However,

$ nohup play mylist.m3u

Does have music play, but I can't disown it, as before.


It seems like all these are related.

Most programs behave well when disowned or run through nohup, but not SoX.

Does anyone know why?

Best Answer

SoX wants/needs input & output... by typing 'play xxxx' in the console, you're running it normally, with stdin & stdout (& stderr) all connected.

When you background the job (with &), it starts, then is paused since it's waiting for access to stdin & stdout.

Same thing occurs when you 'nohup' a job. If it needs keyboard input, it'll "block", and get paused by the system until it receives access to stdin.

disown'ing a process effectively cuts it off from stdin & stdout which were connected to the console which started the process.

It's still "running", but is blocked (paused) by the system since it's waiting for access to stdin & stdout.

Related Question