File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Replaceing popen() function with pipe() and fork() to avoid Linux command df hung.

 
ashish jadhav
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
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?
Thanks,
Ashish
 
ashish jadhav
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
Can anyone do needful?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic