Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Play Audio in Background?' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Play Audio in Background?
Authored by: VxJasonxV on Oct 03, '08 09:56:58AM

Don't worry that you're doing something wrong. You're correct. Using & puts it in the background of the shell, but if you kill the shell, you kill that application as well.

(Applications don't run without a controller of some manner.)

You have two options, and both may be a bit more involved than you want to be.

One is that you can use the 'nohup' command to continue command execution even if the shell goes away. Or you can learn how to use the 'screen' command.

nohup will continue command execution until completion (or failure, either way a program exit), and then it'll go away.
screen is a "terminal multiplexer", it allows you to turn one terminal into many all self contained. It serves an excellent second purpose that if you're doing something (say, ssh'ed into a remote server) and your connection goes away, everything you were doing inside screen continues to run, or everything you have done remains there in context until you reconnect to the server and resume screen.
This of course works locally. Be forewarned this is a VERY extreme example. If you're running screen, and terminal crashes, nothing happens to screen. It's all still there to reconnect to when you re-open Terminal and reconnect to it.
The only thing screen doesn't do is survive a reboot (go figure).

It'll take a little bit of learning to get used to it (the man page is VERY big), but I absolutely swear by screen.

[ Reply to This | # ]
Play Audio in Background?
Authored by: rcbarnes on May 12, '12 04:23:45AM

There's an easier way to close a terminal window (which is not the preferred way to end the shell inside it---similar to using 'force quit' to end safari instead of the quit menu command) without OS X whining or killing the programs you've started:

Instead of ending a command with '&', end it with '& disown' (no quotes, of course).

Note: This will work for essentially *any* program, but if there are semi-colons (;) in the line you typed, you are running more than one program and simply adding ' & disown' to the end of the line may not be sufficient to get the behavior you want.

I am sure the OP gave up on this page long ago, but in case future readers who stumble on this page are daunted by your suggestions (valid though they are), I though this very simple fix would be useful.

[ Reply to This | # ]