Quantcast
Channel: Active questions tagged kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 6333

Is there a way to check whether a given pid match any process in kernel space?

$
0
0

Is there a way to check whether a given pid match any process in kernel space?

I am building a system call that changes the weight of custom weighted round robin scheduler.

I would like to do a check before calling find_task_by_vpid(pid) to avoid calling that function if the pid is invalid (ie. there is no process that have this pid value).

This is because if an invalid pid is used, my virtual machine crashes. So I would like to do a check and return an error value of -ESRCH back to user space.

Is there a checking function for that?

Or is it possible to check whether or not find_task_by_vpid(pid) == NULL to determine if pid is valid or not? I couldn't find a documentation that specify what the return is for find_task_by_vpid(pid) when pid is invalid.

SYSCALL_DEFINE2(set_wrr_weight, pid_t, pid, int, weight){   struct sched_wrr_entity *wrr_se;   // I want to do a check here to see if given pid is valid or not   rr_se = &find_task_by_vpid(pid)->wrr;   wrr_se->wrr_weight = weight;   return 0;}

Viewing all articles
Browse latest Browse all 6333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>