execute a user process in the kernel

Jari Kirma kirma at cs.hut.fi
Wed Sep 22 05:51:47 PDT 2004


Gordon David wrote:

> Hello,

> I have a question. Anyone would like to tell me how to execute a user
> process or shell script in the kernel?

> As we know, the kernel forks a process named initproc and executes
> /sbin/init, etc. If I want to execute a user level process, such as a
> simple printf("Hello world") in a driver, what shall I do?

Proper way to do this is to have userland daemon handling this stuff, 
waiting for device driver using device-specific method (most likely 
a file under /dev). I'm pretty skeptic processes that don't have init 
process as their first ancestor can be created easily at all.

There's also another question to consider: where the output should go? 
These kind of things are better to be handled in the userland.

-kirma


More information about the freebsd-hackers mailing list