472,784 Members | 1,019 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,784 software developers and data experts.

C++ system calls

Gil
I am running a C++ process on Solaris that needs
to find out how much diskspace is free and used on
the system.

Is 'system' in stdlib.h the only way to make OS calls
from C++?

In this case, I will probably be making unix calls like
'df' or 'statvfs' to get the diskspace information and
redirecting it to a file, and then opening and reading
the output.
Gil
Jul 22 '05 #1
12 3352
* br**************@hotmail.com (Gil) schriebt:

Is 'system' in stdlib.h the only way to make OS calls
from C++?
In one sense yes, namely that the standard library is defined
without reference to any particular OS, and that the language
does not directly support OS calls.

In another sense no, namely that 'system' as well as the i/o
facilities in the C and C++ standard libraries in practice uses
OS calls when suitable OS calls are available; they can be
regarded as abstractions over the OS, whatever the OS is.

In a third sense, the OS is probably mostly implemented in C
and/or C++, and a system-specific compiler (as most compilers
are...) will provide some system-specific means of making OS
API calls.


In this case, I will probably be making unix calls like
'df' or 'statvfs' to get the diskspace information and
redirecting it to a file, and then opening and reading
the output.


How to do that is off-topic in this group, but generally, you just
include the relevant headers and link with the appropriate libs.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #2
* br**************@hotmail.com (Gil) schriebt:

Is 'system' in stdlib.h the only way to make OS calls
from C++?
In one sense yes, namely that the standard library is defined
without reference to any particular OS, and that the language
does not directly support OS calls.

In another sense no, namely that 'system' as well as the i/o
facilities in the C and C++ standard libraries in practice uses
OS calls when suitable OS calls are available; they can be
regarded as abstractions over the OS, whatever the OS is.

In a third sense, the OS is probably mostly implemented in C
and/or C++, and a system-specific compiler (as most compilers
are...) will provide some system-specific means of making OS
API calls.


In this case, I will probably be making unix calls like
'df' or 'statvfs' to get the diskspace information and
redirecting it to a file, and then opening and reading
the output.


How to do that is off-topic in this group, but generally, you just
include the relevant headers and link with the appropriate libs.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #3
There are definetly file system related calls in C/C++ like
statfs,fstatfs that gives you information about a mounted file
system. ( Total Number of Blocks allocated, free blocks, block size..etc).
I have worked with these in Linux but never tried in Solaris.

-Sai

br**************@hotmail.com (Gil) wrote in message news:<ad**************************@posting.google. com>...
I am running a C++ process on Solaris that needs
to find out how much diskspace is free and used on
the system.

Is 'system' in stdlib.h the only way to make OS calls
from C++?

In this case, I will probably be making unix calls like
'df' or 'statvfs' to get the diskspace information and
redirecting it to a file, and then opening and reading
the output.
Gil

Jul 22 '05 #4
There are definetly file system related calls in C/C++ like
statfs,fstatfs that gives you information about a mounted file
system. ( Total Number of Blocks allocated, free blocks, block size..etc).
I have worked with these in Linux but never tried in Solaris.

-Sai

br**************@hotmail.com (Gil) wrote in message news:<ad**************************@posting.google. com>...
I am running a C++ process on Solaris that needs
to find out how much diskspace is free and used on
the system.

Is 'system' in stdlib.h the only way to make OS calls
from C++?

In this case, I will probably be making unix calls like
'df' or 'statvfs' to get the diskspace information and
redirecting it to a file, and then opening and reading
the output.
Gil

Jul 22 '05 #5
Saikrishna wrote:
br**************@hotmail.com (Gil) wrote in message news:<ad**************************@posting.google. com>...
I am running a C++ process on Solaris that needs
to find out how much diskspace is free and used on
the system.

Is 'system' in stdlib.h the only way to make OS calls
from C++?

In this case, I will probably be making unix calls like
'df' or 'statvfs' to get the diskspace information and
redirecting it to a file, and then opening and reading
the output.
Gil There are definetly file system related calls in C/C++ like
statfs,fstatfs that gives you information about a mounted file
system. ( Total Number of Blocks allocated, free blocks, block

size..etc). I have worked with these in Linux but never tried in Solaris.

-Sai


1. Its Annoying.
2. So don't Top-Post. Replies are either interspersed
or appended to the bottom, like this one.

By the way, statfs, fstatfs are not standard calls in
either C or C++. And yes, they are two different
languages. There is not one language called C/C++.

If you believe the above are _standard_ functions,
please correct me by quoting the ISO/ANSI specification.
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 22 '05 #6
Saikrishna wrote:
br**************@hotmail.com (Gil) wrote in message news:<ad**************************@posting.google. com>...
I am running a C++ process on Solaris that needs
to find out how much diskspace is free and used on
the system.

Is 'system' in stdlib.h the only way to make OS calls
from C++?

In this case, I will probably be making unix calls like
'df' or 'statvfs' to get the diskspace information and
redirecting it to a file, and then opening and reading
the output.
Gil There are definetly file system related calls in C/C++ like
statfs,fstatfs that gives you information about a mounted file
system. ( Total Number of Blocks allocated, free blocks, block

size..etc). I have worked with these in Linux but never tried in Solaris.

-Sai


1. Its Annoying.
2. So don't Top-Post. Replies are either interspersed
or appended to the bottom, like this one.

By the way, statfs, fstatfs are not standard calls in
either C or C++. And yes, they are two different
languages. There is not one language called C/C++.

If you believe the above are _standard_ functions,
please correct me by quoting the ISO/ANSI specification.
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 22 '05 #7

"Gil" <br**************@hotmail.com> wrote in message
news:ad**************************@posting.google.c om...
I am running a C++ process on Solaris that needs
to find out how much diskspace is free and used on
the system.

Is 'system' in stdlib.h the only way to make OS calls
from C++?


No - I think you will find that popen is std C and more directly useful than
system
because it gives you a FILE* to pipe in teh result.

The actual progs are OS specific and hence not C++ but I think you will
find that there are API calls.

RTFM :-)

Jul 22 '05 #8

"Gil" <br**************@hotmail.com> wrote in message
news:ad**************************@posting.google.c om...
I am running a C++ process on Solaris that needs
to find out how much diskspace is free and used on
the system.

Is 'system' in stdlib.h the only way to make OS calls
from C++?


No - I think you will find that popen is std C and more directly useful than
system
because it gives you a FILE* to pipe in teh result.

The actual progs are OS specific and hence not C++ but I think you will
find that there are API calls.

RTFM :-)

Jul 22 '05 #9
Nick Hounsome wrote:
"Gil" <br**************@hotmail.com> wrote in message
news:ad**************************@posting.google.c om...
I am running a C++ process on Solaris that needs
to find out how much diskspace is free and used on
the system.

Is 'system' in stdlib.h the only way to make OS calls
from C++?

No - I think you will find that popen is std C and more directly useful than
system
because it gives you a FILE* to pipe in teh result.


No, he will not find that popen() is standard C. It's not. Nor is it
standard C++.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #10
Nick Hounsome wrote:
"Gil" <br**************@hotmail.com> wrote in message
news:ad**************************@posting.google.c om...
I am running a C++ process on Solaris that needs
to find out how much diskspace is free and used on
the system.

Is 'system' in stdlib.h the only way to make OS calls
from C++?

No - I think you will find that popen is std C and more directly useful than
system
because it gives you a FILE* to pipe in teh result.


No, he will not find that popen() is standard C. It's not. Nor is it
standard C++.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #11
Gil <br**************@hotmail.com> spoke thus:

<point granularity="fine" confidence="7/10">
Is 'system' in stdlib.h the only way to make OS calls
from C++?


system() does not allow you to make "OS calls". What it does
do is pass a command string to a shell or other command
interpreter (DOS, bash, ksh, whatever), which may or may not
issue system calls to handle the command. If you wish to issue
the system calls yourself (your next paragraph suggests that you
do), you must employ implementation-specific extensions to C/C++
which are, as others have noted, not to be discussed here.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 22 '05 #12
Gil <br**************@hotmail.com> spoke thus:

<point granularity="fine" confidence="7/10">
Is 'system' in stdlib.h the only way to make OS calls
from C++?


system() does not allow you to make "OS calls". What it does
do is pass a command string to a shell or other command
interpreter (DOS, bash, ksh, whatever), which may or may not
issue system calls to handle the command. If you wish to issue
the system calls yourself (your next paragraph suggests that you
do), you must employ implementation-specific extensions to C/C++
which are, as others have noted, not to be discussed here.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 22 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Birch | last post by:
I have a python script that uses the print function throughout, and as well uses calls to os.system() to spawn DOS commandline executables. My issue is that I redirect all of the output from this...
12
by: Gil | last post by:
I am running a C++ process on Solaris that needs to find out how much diskspace is free and used on the system. Is 'system' in stdlib.h the only way to make OS calls from C++? In this case,...
8
by: Peter Olcott | last post by:
Is there any way to intercept system calls to windows such as TextOut and DrawText? what kinds of system calls can be intercepted, and what is the mechanism to accomplish this?
5
by: markus | last post by:
Hi, I have a question that deals with the standard c library VS (Unix) system calls. The question is: which header files (and functions) are part of the C library and which header files (and...
22
by: markus | last post by:
Hi, There are more than 1000 defined system calls in the Unix standard specification, however, a majority of them are optional and the availability of system calls are dependent on the OS...
7
by: rahul8143 | last post by:
hello, what is difference between system call and library function call? Does library function call can have context switch to kernel mode? regards, rahul
11
by: talk | last post by:
hi,guy i have a question. are the functions in <stdio.h> system calls provided by operation system? if so, i want to know how C implements that we can call system calls by using the functions in...
3
by: Carlos Lozano | last post by:
I have requirement to pause the system clock until a certain event (Win XP). Then the clock will be resumed to the real time. I think it can be done using core functions and/or redirecting the...
21
by: omkar pangarkar | last post by:
Hi all, I have two simple hello world programs one using printf() and other using write() --prog 1-- #include<stdio.h> #include<stdlib.h> int main() { printf("Hello"); /* up to here...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.