There are two ways to terminate para_audiod in a controlled way:
by executing the "term" command and by sending SIGINT or SIGTERM
to the process. Currently both code paths call clean_exit() from
some ->post_select function, which terminates para_audiod by calling
exit(3). Despite the name, this is "unclean" because tasks are not shut
down properly, so not all memory can be freed by this approach. While
this is not a big problem, it makes it more difficult to debug real
memory leaks.
This patch tries to overcome this problem by using notifications to
shut down the audiod tasks. Two new error codes E_AUDIOD_TERM and
E_AUDIOD_SIGNAL are introduced for the notification values. All tasks
are modified to check for notifications and now return the (negative)
notification value from their ->post_select() method if a notification
was received. Hence schedule() returns to main() and we may clean up
the resources allocated by the scheduler by calling sched_shutdown(),
along with the usual cleanup performed by clean_exit(). The latter
function is renamed to audiod_cleanup(), which is more to the point.