[alsa-devel] How to kill thread server_job() in snd_pcm_open()
r93922118 at ntu.edu.tw
Mon Apr 14 04:18:00 CEST 2008
Rong-Jhe <r93922118 <at> ntu.edu.tw> writes:
> I found that the thread server_job() can not be killed by using snd_pcm_close
> The code in snd_pcm_direct_server_discard() is disabled, and then it can not
> send signal to kill the thread.
> Why the code is disabled?
> Is there any bugs if I enable the code?
I have enabled the code in snd_pcm_direct_server_discard(), but it can not
kill the thread of server_job(). The dmix->server_pid is wrong.
In snd_pcm_direct_server_create(), the main thread uses fork() to establish a
child thread and the child uses fork() to establish another child thread again.
The main thread only keeps the pid of the first child thread, and the second
child thread executes server_job(). Do to this, the main thread kills wrong
Further, the main thread uses waitpid() before keeping the pid of the first
child thread, and the first child thread dies after establishing the second
child thread. In this way, the pid kept in dmix->server_pid is useless.
Why does the program need to use fork() two times?
More information about the Alsa-devel