2016-09-25 241 views
0

對於給定的pid_t pid,我使用find_get_pid()調用來獲得struct pid *,即進程ID。不過,我想包括一些健全性檢查,因爲pid值將由用戶進程提供,假設用戶給出的pid值爲123,並且不存在具有pid 123的進程,那麼將返回find_get_pid返回的錯誤值。它會返回一個NULL指針嗎?find_get_pid()內核函數的錯誤值是什麼?

示例代碼存根如下:

struct pid *pid_struct; 
    struct task_struct *task; 

    pid_struct = find_get_pid(pid); 
/* INSERT SANITY CHECK ON pid_struct ? */ 
    task = pid_task(pid_struct, PIDTYPE_PID); 

回答

0

是的,從find_get_pid錯誤返回()將一個NULL指針。 (使用來源,盧克)。