Solved

disk space available for the process to run

Posted on 2004-04-23
5
261 Views
Last Modified: 2010-04-15
i want to ask a question regarding the space required to run a process in hp unix
i am running a process which is purging tables.. and also writing the details to a file generated on the unix system

but i want to make sure that disk space is available for the process to run
from the program, how to check for this and alert the user about the space available ?

all ideas welcome..
0
Comment
Question by:santoshv25
  • 2
  • 2
5 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 10897307
Hi santoshv25,

from your program run df command and check the free space available ... If it is less than minimum requirements of your program, show error

system ("df"); or fork and exec df if you like

Sunnycoder
0
 

Author Comment

by:santoshv25
ID: 10897329
df command is fine.
but everytime i run df, it shows the full disk space available for all the system blocks

but if the user is running this process, then how to check this ? i mean will it not be better if i find the available space available for the current system ?
0
 
LVL 12

Expert Comment

by:stefan73
ID: 10897349
Hi santoshv25,
> i want to make sure that disk space is available for the process to run
This is quite tricky, as the disk space can change by other users creating and deleting files.

As Sunny suggested, an initial "df" (or perhaps "df -k .") makes sense. But you can still encounter space problems during your run (not only those, you can also fill your quota!).

There are several possibilities:
1. Use a safety margin. If you plan to allocate 1M, either check if you have x*1M, or you add a margin, regardless of your requirement.
2. Continously check the available space while your program is running. "df" checks are relatively expensive, so calling it more than, say, every 5 seconds, is stressing your file system unnecessarily. Once you detect a "yellow" high-water mark, you can still do a "graceful" shutdown, instead of a hard abort when encountering a "red" mark.

Normally, you'd combine both methods. A "df" check thread could be a solution.

Cheers,
Stefan
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 40 total points
ID: 10897390
better still ... Whenever a system call returns, check its return value ... In case of disk space errors, you will get ENOSPC ... or when out of memory you get ENOMEM
0
 
LVL 12

Expert Comment

by:stefan73
ID: 10897433
> you will get ENOSPC ... or when out of memory you get ENOMEM

Yes, also check for EDQUOT in case of quotas.

Stefan
0

Featured Post

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question