I need to run a linux command such as “df” from my linux daemon to know free space,used space, total size of the parition and other info. I have options like calling system,exec,popen etc..
-
But as this each command spawn a new process , is this not possible to run the commands in the same process from which it is invoked?
-
And at the same time as I need to run this command from a linux daemon, as my daemon should not hold any terminal. Will it effect my daemon behavior?
Or is their any C or C++ standard API for getting the mounted paritions information
There is no standard API, as this is an OS-specific concept.
However,
/proc/mounts(or/etc/mtab) with (non-portable)getmntent/getmntent_rhelper functions.statfs.