C ++系统调用 [英] C++ system calls

查看:106
本文介绍了C ++系统调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Solaris上运行一个需要

的C ++进程,以查明系统中有多少磁盘空间是免费的并且在

上使用。

stdlib.h中的''system''是进行OS调用的唯一方法
来自C ++的



在这种情况下,我可能会发出unix调用,比如

''df''或''statvfs''来获取磁盘空间信息和

将它重定向到一个文件,然后打开阅读

输出。

Gil

解决方案

* br ************** @ hotmail.com (Gil)schriebt:< blockquote class =post_quotes>
stdlib.h中的''system''是从C ++进行OS调用的唯一方法吗?


从某种意义上来说,是标准库定义

而不参考任何特定的操作系统,而且语言是

不直接支持操作系统调用。


从另一个意义上说,没有,即''system''以及i / o

设施实际上,C和C ++标准库在适当的OS调用可用时使用

OS调用;无论操作系统是什么,它们都可以被视为操作系统的抽象。


从第三种意义上说,操作系统可能主要是用C实现的。 />
和/或C ++,以及特定于系统的编译器(因为大多数编译器

都是......)将提供一些特定于系统的制作OS的方法

API调用。


在这种情况下,我可能正在进行unix调用,如
''df''或''statvfs''来获取磁盘空间信息和
将其重定向到一个文件,然后打开并阅读输出。




如何做到这一点在这个组中是偏离主题的,但一般情况下,你只需要

包含相关的标题并链接到相应的库。


-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么顶级发布这么糟糕的事情?

A:热门发布。

问:usenet和电子邮件中最烦人的是什么?

* br *********** ***@hotmail.com (Gil)schriebt:


stdlib.h中的''system''是进行OS调用的唯一方法
C ++?


从某种意义上来说,是标准库定义

而不参考任何特定的操作系统,而且语言是

不直接支持操作系统调用。


从另一个意义上说,没有,即''system''以及i / o

设施实际上,C和C ++标准库在适当的OS调用可用时使用

OS调用;无论操作系统是什么,它们都可以被视为操作系统的抽象。


从第三种意义上说,操作系统可能主要是用C实现的。 />
和/或C ++,以及特定于系统的编译器(因为大多数编译器

都是......)将提供一些特定于系统的制作OS的方法

API调用。


在这种情况下,我可能正在进行unix调用,如
''df''或''statvfs''来获取磁盘空间信息和
将其重定向到一个文件,然后打开并阅读输出。




如何做到这一点在这个组中是偏离主题的,但一般情况下,你只需要

包含相关的标题并链接到相应的库。


-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么顶级发布这么糟糕的事情?

A:热门发布。

问:usenet和电子邮件中最烦人的是什么?

在C / C ++中存在与文件系统相关的调用,例如

statfs,fstatfs,它为您提供有关已安装文件的信息

系统。 (已分配的块总数,空闲块,块大小等。)

我在Linux中使用过它们但从未在Solaris中使用过。


-Sai

br *********** *** @ hotmail.com (吉尔)在留言中写道:< ad ************************** @发帖。谷歌。 com> ...

我正在Solaris上运行一个C ++进程,需要
来查找系统上有多少空闲和使用的磁盘空间。

stdlib.h中的''system''是从C ++进行OS调用的唯一方法吗?

在这种情况下,我可能正在进行unix调用,如
''df''或''statvfs''获取磁盘空间信息并将其重定向到文件,然后打开并读取输出。

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

解决方案

* 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?


* 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?


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



这篇关于C ++系统调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆