Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I m a newbie to linux. Can someone help me on how to Create a module that uses the /proc file system to return a list of all pids ...
  1. #1
    ann
    ann is offline
    Just Joined!
    Join Date
    Oct 2009
    Posts
    1

    Create a module that uses the /proc file system to return a list of all pids and ppid



    Hi,
    I m a newbie to linux. Can someone help me on how to Create a module that uses the /proc file system to return a list of all pids and ppids for processes om the system . I googled and found the following:

    #include < linux/kernel.h >
    #include < linux/sched.h >
    #include < linux/module.h >

    int init_module(void)
    {
    struct task_struct *task;
    for_each_process(task)
    {
    printk("%s [%d]\n",task->comm , task->pid);
    }

    return 0;
    }

    void cleanup_module(void)
    {
    printk(KERN_INFO "Cleaning Up.\n");
    }

    But I need to read pids, ppids from the /proc file and not from the module
    Can someone help me with this. Thanks in advance.

  2. #2
    Just Joined! chris81's Avatar
    Join Date
    Jan 2009
    Posts
    62
    Hi

    This ps works by reading the virtual files in /proc.

    from

    UNIX man pages : ps ()

    You can also refer to your ps man page.

    Hope it helped
    chris81

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •