Find the answer to your Linux question:
Results 1 to 7 of 7
HI, I want to write programe to get syslogd.pid , will you guide me for this ? Thanks ,...
  1. #1
    Just Joined!
    Join Date
    Dec 2007
    Location
    Bangalore >> India
    Posts
    28

    Exclamation How will i get syslogd.pid ?

    HI,

    I want to write programe to get syslogd.pid , will you guide me for this ?

    Thanks ,

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Quote Originally Posted by amaresh_83 View Post
    HI,

    I want to write programe to get syslogd.pid , will you guide me for this ?

    Thanks ,
    You can run the command "ps -e | grep syslogd" and look at the first field in the returned string. That is the process ID for syslogd.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    Also
    Code:
    pgrep syslogd
    will work on Linux and Solaris (of recent vintage) ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  4. #4
    Just Joined!
    Join Date
    Dec 2007
    Location
    Bangalore >> India
    Posts
    28
    Quote Originally Posted by Rubberman View Post
    You can run the command "ps -e | grep syslogd" and look at the first field in the returned string. That is the process ID for syslogd.
    I am not asking linux command as how to get ?. I am asking how will i write programe foe it not shel script but c programe.

  5. #5
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    So you wish to do what code in ps does. For that, note:
    Code:
    ... ps works by reading the virtual files in /proc ...
    
    -- excerpt from man ps
    which suggests you should look at man proc.

    Best wishes ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  6. #6
    Just Joined!
    Join Date
    Dec 2007
    Location
    Bangalore >> India
    Posts
    28
    No,
    i wanted to write a programe for syslogd.pid , example,

    Code:
    #include<stdio.h>
    int
    main()
    {
         printf("Hello World\n");
         return 0;
    }
    
    will print :- Hello World
    like wise i want to write programe for syslogd.pid

    Thanks,
    Computer And Technologies

  7. #7
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Quote Originally Posted by amaresh_83 View Post
    I am not asking linux command as how to get ?. I am asking how will i write programe foe it not shel script but c programe.
    Sorry, but I don't know if there is a specific function call that can get you information from /proc by name. Most people would pipe the output from the pgrep command to a temporary file and then use your C program to read the file and place the output into a variable.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

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