Read the documentation for various "background" modules, such as Net::Server, Proc::Daemon, and the like. They will likely be very informative.
In the meantime, try this test. Run your application with stdin redirected from /dev/null. My bet is that you'll find other problems, but that hanging isn't one of them.
Well, that's the Bourne-shell syntax. If you're using tcsh, I'm not sure what it'll look like.yourscript.pl < /dev/null &
The issue is that anything running in the "background" needs to not rely on stdin for anything. It shouldn't rely on stdout or stderr, either, but that's somewhat less hard and fast of a rule. Some programs have a "background" mode where they close stdin right away to prevent accidental reads from stdin. Then others have a full daemon mode where they use one of the above modules (or, in other languages, the same concepts) to completely pull themselves away from the session that started them to render themselves immune to this type of problem - including the dying during logout.
In reply to Re: Script hangs or dies when run in background. Works fine in foreground.
by Tanktalus
in thread Script hangs or dies when run in background. Works fine in foreground.
by mears11
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |