- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我们知道 unistd.h 是一个重要的头文件,但是我不确定它是来自内核源代码还是在我们安装 libc 之前安装的?
最佳答案
在软呢帽
# rpm -qf /usr/include/unistd.h
eglibc-headers-2.13-2.21.i686
我们可以在头文件中看到这部分
this file is part of the GNU C Library.
而在内核版本2.6.32.21中我们可以看到
/* kernel/include/linux/unistd.h */
#include <asm/unistd.h>
我们假设 X86
/* kernel/arch/x86/include/asm/unistd.h */
# ifdef CONFIG_X86_32
# include "unistd_32.h"
# else
# include "unistd_64.h"
# endif
并且在文件中有系统调用。不是我们通常使用unistd.h
/*
* This file contains the system call numbers.
*/
#define __NR_restart_syscall 0
#define __NR_exit 1
#define __NR_fork 2
#define __NR_read 3
#define __NR_write 4
#define __NR_open 5
#define __NR_close 6
#define __NR_waitpid 7
#define __NR_creat 8
关于c -/usr/include/unistd.h 和 limit.h 来自 glibc 或内核,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16826909/
这两个文件有什么区别?我真的无法理解。我应该提到第一个文件应该是 arch/x86/include/asm/unistd_32.h(或 _64.h)。以下是它们包含的内容的快速预览: arch/x86
在下面的代码片段中,无论我输入多长时间(编辑:我复制并粘贴到一个随机字符串),假设一个包含 9998 个字符的字符串,read() 在 i = 4095 时停止。它声明它读取的是 EOF 字符,但我的
标准unix C具有此功能: ssize_t read(int fd, void *buf, size_t count); 但是,此“读取”功能可以读取1次的最大字节数是多少? 最佳答案 通常,它可以
我已经在学校用 Mac 编程一个月了。我们在 UNIX shell 上进行 C 编程。 现在我回到家,我使用自己的 Windows 10 电脑。我尝试过进行类似的设置,但我对此不太了解。我安装了 gi
我正在尝试使用 unistd 库写入/读取文本文件。稍后我会把它部署到/dev路径下的一个文件中。我正在尝试使用 std::vector 类型而不是 char buffer[]。所以我写了两个实现,一
如何查看函数 execve 的实现(在 x86_64 Linux 下),它在库 unistd 中?我想要这个是因为我想知道如何在不调用 execve 的情况下使用汇编程序调用外部程序。我知道有一个名为
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
假设我无法访问任何 C 标准库,我尝试使用 write(x, x, x) 函数打印 2 位整数。我只包含 根据规范。我当前的函数仅提供传递给它的值的 ASCII 表示形式。 void my_print
除此之外,我的程序应该将任何小于 32 且大于 126 的字符存储为句点 (.)。然后应该打印出这个时期。 例如,如果将换行符传递给我的打印函数,它应该将其存储为句点,并在其位置打印出句点。 (我不允
我正在编写一个支持键盘/光标的小内核。一切都工作得很好,直到我添加了 unistd.h 中的函数 内核.c #include "keyboard_map.h" #include "keyboard.c
我想用 unix 域套接字实现一个服务器/客户端程序。该程序1. 启动时,在抽象命名空间中创建一个套接字和一个 unix 地址2. 尝试将套接字绑定(bind)到该地址,如果绑定(bind)失败并返回
我正在从命名管道读取/写入数据。在写入方面,它表示它正在写入一个常量 110 字节。在读取方面,大部分时间它说它正在读取 110 个字节,这是正确的,但其他时候它说它正在读取 220 个字节或 330
我一直在尝试通过使用系统调用(read()、write()、open()、close())在 unix/linux 中执行 cp 命令的 c 编程实现。 但是当我通过终端运行我的程序时,通过将该程序的
我正在学习 UNIX 编程并尝试读/写系统调用。我有一个包含一对整数的文件: 4 5 我写了这段代码来读取数字: #include #include #include #include #in
我使用的是 VisualStudio 2012 并在 windows 7 计算机上运行。 我想在我的Windows机器下执行命令make all。为此我安装了Make for Windows 。 此外
我出于教育目的探索这些库并遇到文件 os_defines.h ,它在我的 MacBoook 上位于 usr/include/c++/4.2.1/bits 。我在那里找到#include ,所以我快速
在我的代码中,我需要执行 /bin/bash,但我不想在不向它传递任何参数的情况下执行它。我写了这个: execl("/bin/bash", NULL); 然后,通过一些研究,我意识到我还需要添加类型
我试图通过管道进入读取,但它在第二个输入后一直出现段错误。我究竟做错了什么?提前致谢。 $ ./read #include void prompt_name(char *name, char *
据说在C++中包含C头文件时,要去掉“.h”后缀,然后在开头加上“c”。例如,#include 而不是 #include .但是当我使用 sleep()在我的代码中,#include 不起作用,但是
这是我的代码(只是为了测试 fork() 而创建): #include #include #include #include #include #include int main() {
我是一名优秀的程序员,十分优秀!