When developing a userspace application or daemon, it is good design practice to provide some form of component status. I have often thought of using /proc for this purpose - is this an acceptable solution? Perhaps there is a userspace library that replicates /proc services?

Most other references that I have found indicate that /proc is reserved for kernel and driver developers.

  • You can create a subdirectory under /var/run, containing a read-only file that contains status, or a read-write socket or named pipe if you'd like a way to have a program interact with the daemon. For more complex interaction, you can create a fuse filesystem, which can do everything /proc can do. – Mark Plotnick Jul 27 '15 at 5:52

Indeed, /proc is reserved for kernel space. On Linux, it's a special fs type "procfs", and every file is a handler to some function inside the kernel.

You can't create a folder/file in /proc while being in userland. You may create a kernel module which will talk back to your process, but it won't be a good idea, as you'll have serious security issues. This, without saying the huge risk of memory corruption is something goes wrong.

Anyway, you may take example on the inotify library (userland & kernel) : see the manpage and here's a sample of a kernel module code for creating an entry in /proc : http://linux.die.net/lkmpg/x769.html

Happy hacking :)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.