Solved

disk space available for the process to run

Posted on 2004-04-23
5
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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 recursion in the C programming language.
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.

617 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