Okay, I have the following coded up:
Default behavior is for exit() in main or a thread to exit
the app.
If there are unjoined threads (running or finished),
then a warning is given. (Detached theads are ignored.)
If a thread exits, this warning can be suppressed
with: no warnings 'threads'
If the main thread exits, this warning can't be
suppressed. (Warning is given as part of global
destruction, so warning bits are no longer
available.)
There is a thread-exit-only class method: threads->exit()
If called from main, it acts like 'exit(0)', complete
with warning message as per above, if applicable.
If called in a thread, terminates just the thread
without any warning.
The default behavior for exit() in threads can be changed in
several ways:
Global change
use threads 'exit' => 'threads_only';
# or
use threads 'exit' => 'threads';
At thread creation
threads->create({'exit' => 'thread_only'}, ...);
# or
threads->create({'exit' => 'thread'}, ...);
After thread creation
threads->set_thread_exit_only(); # Inside a thread
# or
$thr->set_thread_exit_only();
When a thread dies, it issues a warning. It the thread's
warning handler subsequently issues an 'exit()', that exit
will operate as per the above.
The exit status (i.e., exit(status)) is preserved and
propogated to the shell.
Comments? Should the exit-override functionality be
scrapped?