Even if you write a kernel driver, iterating over all tasks in the system is a terrible design (there may be millions), not to mention "determining if a task belongs to a C playground program" in the kernel (obviously the kernel should have no knowledge about such specifics).
Of course, if a developer cannot even produce a reasonable overall design, it's not surprising that they aren't capable of writing correct code.