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);