此处用了一个播放madplay的应用程序作为记录。里面有几个地方用到了kill,分别来进行播放音乐进程的开始、暂停、停止等操作:
#include #include #include #include #include #include #include
int main()
{
char ch;
int MIX_FD;
int iLeft = 60;
int iRight = 20;
int iLevel;
MIX_FD= open("/dev/mixer", O_WRONLY);
if (MIX_FD == -1)
{
perror("Error:open /dev/mixer error");
exit(1);
}
printf ("[a] Play \n");
printf ("[b] Pause \n");
printf ("[c] Resume\n");
printf ("[d] stop \n");
printf ("[+] Up Vol\n");
printf ("[-] Down Vol\n");
printf ("[e] Exit \n");
while(1)
{
printf("Please enter your choice: ");
scanf("%c",&ch);
printf("\n");<