This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
We have C class (sysclckpi) in which we are using do_PCTDSKFRE function.
1 The function do_PCTDSKFRE in sysclckpi calculates the free disk space.
2 In do_PCTDSKFRE function the function popen() executes the Linux command [popen(df -km /u01 2>&1 | grep -v Mounted 2>&1)] i.e. df which returns disk used space in percentage from which free space can be calculated.
3 After searching on Internet we found that lots of people are facing same problem of process hang out for df command in Linux sometimes.
4 We are planning to replace popen() function with pipe() and fork() methods,so sysclckpi will continue without hanging and therefore not be killed off.
Can anyone please do needful? or how can i replace popen() function with pipe() and fork() functions?
You're asking the wrong question, my friend. The right question is "should we use a pipe to df to find out disk usage on Linux?" The answer is an emphatic "no". Use statfs() -- try "man statfs" to learn about it.