SIGTTIN

看名字倒是挺容易發現這是一種 Signal。先來說說故事好了。最近接了一個撰寫 protocol 的案子,為了測試方便,我幫程式加了一個簡單的 command line interface。作法很簡單,我在程式裏面的 fd 處理地方多加了一個 stdin 的 callback function,然後在函式裏面進行處理。

問題來了,當我們把程式移交給客戶的時候,客戶將這隻 daemon 以背景的模式運行,結果程式就不會動了??為什麼??

答案就在標題中。

http://www.lindevdoc.org/wiki/SIGTTIN 看到的資料如下:

The SIGTTIN signal is sent to a process when it attempts to read from the terminal but is not in the foreground group. By default, this signal causes the receiving process to temporarily stop; the system will automatically reactivate it (with the SIGCONT signal) when its group gets into foreground. However, this signal can be blocked, ignored or caught.

英文很簡單就不多加說明了,可以用 man 7 signal 來觀看相關資料。

留言

這個網誌中的熱門文章

我弟家的新居感恩禮拜分享:善頌善禱

如何將Linux打造成OpenFlow Switch:Openvswitch

Openssl 範例程式:建立SSL連線