Find the answer to your Linux question:
Results 1 to 3 of 3

Thread: process monitor

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    process monitor


    i am writing a simple application which start 2 threads in it.
    i am writing one more application that will monitor this application if it is alive or killed. if killed i need to restart it.

    in /proc/<process pid>/ i will get all the information regarding that process.
    as i am writing a c program how can i get the process pid so that i can search in /proc. example code will appreciated

  2. #2

    Thumbs up

    Hi Maggi,

    Please find the below sample code to run unix command & get the result into output string

    int run_unix_command(const char *command,char *output)
    FILE *file;
    char line[512];
    int ret = -1;
    file = popen(command , "r");
    if (file != NULL)
    if (fgets(line , sizeof ( line ) , file) == NULL)
    ret = -1
    ret = 1;
    return ret;

    A community site where you can try Open Source software for free. right in your browser.

  3. #3
    Thanks lakshika,

    It is working for me and i am able to get he PID for that

  4. $spacer_open

Posting Permissions

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