[問題] userspace & kernel space 溝通

作者: yshihyu (yshihyu)   2016-03-16 21:47:59
https://gist.github.com/anonymous/bb7623c4c2c2b31fe288
因為程式碼有點多所以我貼再上面網址裡面
我程式是想從 使用者空間的appln process 透過 ioctl 傳遞 process 的
pid 到 kernel , kernel 再透過 send_sig 函數不斷發 SIGUSR2 給用使用者空間的
appln prcoess , 當我不想kernel 再發 SIGUSR2 signal .
我再透過 ioctl 讓 kernel 停止發 SIGUSR2
下面是打印出來的log 是正常的
// user space log
PID=6897
Ioctl executed
signal_handler 12, pid=6897
SIGUSR2
signal_handler 12, pid=6897
SIGUSR2
^Cstop_sig=2, pid=6897 // ctrl + c 發往 kernel 讓kernel停止發送 SIGUSR2
// kernel log
[ 681.335568] vrmonitor_sig_handler current pid=6898 send to PID=6897
[ 682.339540] vrmonitor_sig_handler current pid=6898 send to PID=6897
[ 682.871588] IOCTL_STOP_SIG send_sig_flag=0 // kernel 收到停止發送
[ 682.871646] Module Released
[ 683.343531] vrmonitor_sig_handler current pid=6898 send to PID=6897
我再一般pc上運行正常 ,
可是再 vmware ubuntu kernel 只發兩次 SIGUSR2 , 就打印出 Module Released
下面 log , user space 的 appln prcoess 就莫名其妙結束 , 我還沒按 ctrl+c
只是啟動 sudo ./appln 這樣
[ 681.335568] vrmonitor_sig_handler current pid=6898 send to PID=6897
[ 682.339540] vrmonitor_sig_handler current pid=6898 send to PID=6897
[ 682.871646] Module Released
請問可能是什麼原因會有這樣怪異現象?
謝謝
作者: ah7675 (阿毛)   2016-03-16 23:16:00
請愛用netlink
作者: leolarrel (真.粽子無雙)   2016-03-21 18:43:00
請愛用netlink
作者: impotent (奧井大姊我愛你啊)   2016-03-28 08:54:00
改用netlink

Links booklink

Contact Us: admin [ a t ] ucptt.com