A message for Linux.com registered users: We are in the process of making changes to the Linux forums. Starting Monday, 8/13/18 at 6:00 PM PT, you will be unable to access the forums. They will re-launch as soon as possible on Wednesday, 8/15/18 with new features and improved functionality. Thank you for your patience and stay tuned for the new improved forums.
Replication the ps -ef function
Hey everyone, I am trying to create my own ps -ef function inside a linux kernel. For example, ps -ef prints all the information currently running on the computer. To start off I only want to print like 2-3 processes. For example, when the user runs the module it should output (notice how it is the same format as the ps -ef function):
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 15:23 ? 00:00:05 /sbin/init
root 2 0 0 15:23 ? 00:00:05 [kthreadd]
root 3 2 0 15:23 ? 00:00:05 [ksoftirqd/0]
On terminal you can print a process info by knowing the process id (PID): ps -p 1
Is there any built in linux function I can use that does the same thing?