0

I was actually searching for the way to execute the output of bash built-in commands through a C program. Specifically I want to get the output of no.of processes running in the system through a C program . I found the command , now I want to get that through a C code . Can anyone help me out of this ?

NealCaffery
  • 522
  • 6
  • 14
  • 4
    Why don't you use the `getrlimit` system call? – Kerrek SB Sep 20 '14 at 14:30
  • Is it to get the no.of processes running in the system?? – NealCaffery Sep 20 '14 at 14:33
  • Take a look at this question: http://stackoverflow.com/questions/939778/linux-api-to-list-running-processes – MByD Sep 20 '14 at 14:36
  • 1
    How does `ulimit` give you that information? – mafso Sep 20 '14 at 14:50
  • `ulimit -u` was giving the maximum no.of process that are available for the user – NealCaffery Sep 20 '14 at 14:56
  • Yes, and you can get the same information with `getrlimit`. But that's not the number of processes currently running, what is how I understood your question. – mafso Sep 20 '14 at 16:02
  • run the desired command via the system() call with piping the output of the command to a file. Then have your program open that file for read/input. Then read the contents of the file, Then for cleanup, use a system() call to delete the file. – user3629249 Sep 22 '14 at 06:10

0 Answers0