getting currently running processes in C - Unix

This is a discussion on getting currently running processes in C - Unix ; Hi, As in title above, I' m writing a small C program under linux, and it requires a list of currently running processes. As I looked through the net the way to do that is to proces the /proc directory. ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: getting currently running processes in C

  1. getting currently running processes in C

    Hi,
    As in title above, I' m writing a small C program under linux, and it
    requires a list of currently running processes. As I looked through the net
    the way to do that is to proces the /proc directory. Any other ideas ? Does
    Unix have any suitable functions to handle this ? , cheers.




  2. Re: getting currently running processes in C

    On Jun 5, 5:33 pm, "Thomas" wrote:
    > Hi,
    > As in title above, I' m writing a small C program under linux, and it
    > requires a list of currently running processes. As I looked through the net
    > the way to do that is to proces the /proc directory. Any other ideas ? Does
    > Unix have any suitable functions to handle this ? , cheers.


    man ps

    proclist.c
    #include
    #include

    int
    main(void)
    {
    FILE *ps = popen("ps -leaf","r");
    char buf[256] = {0};

    for(;fgets(buf,sizeof(buf),ps)
    printf("%s\n",buf);

    pclose(ps);

    return(0);
    }

    cj


  3. Re: getting currently running processes in C


    "Thomas" wrote in message
    news:f44kql$bc0$5@inews.gazeta.pl...
    > Hi,
    > As in title above, I' m writing a small C program under linux, and it
    > requires a list of currently running processes. As I looked through the
    > net the way to do that is to proces the /proc directory. Any other ideas ?
    > Does Unix have any suitable functions to handle this ? , cheers.


    man ps
    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Aero Stability and Controls Computing



+ Reply to Thread