Linux I/O篇
2016-01-27 09:42
369 查看
Test1:
Test2:
文件描述符的一些信息
lili@lili-linux:~$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 3823
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 3823
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
lili@lili-linux:~$ cat /proc/sys/fs/file-max
97384
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> int main(int argc,char *argv[]) { char buf[128]; memset(buf,0x00,sizeof(buf)); int len = read(STDIN_FILENO,buf,sizeof(buf)); write(STDOUT_FILENO,buf,len); return 0; }
Test2:
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> #include <string.h> int main(int argc,char *argv[]) { if(argc < 3) { printf("inupt error!");//了解printf刷新缓冲的机制 sleep(10); return 0; } int len; int fd_src,fd_dest; fd_src = open(argv[1],O_RDONLY); fd_dest = open(argv[2],O_CREAT|O_WRONLY|O_TRUNC,0777); char buf[1024]; while(len = read(fd_src,buf,sizeof(buf))) { write(fd_dest,buf,len); } close(fd_src); close(fd_dest); printf("success!@!\n"); return 0; }
文件描述符的一些信息
lili@lili-linux:~$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 3823
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 3823
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
lili@lili-linux:~$ cat /proc/sys/fs/file-max
97384
lili@lili-linux:~$ cat /usr/include/asm-generic/errno-base.h #ifndef _ASM_GENERIC_ERRNO_BASE_H #define _ASM_GENERIC_ERRNO_BASE_H #define EPERM 1 /* Operation not permitted */ #define ENOENT 2 /* No such file or directory */ #define ESRCH 3 /* No such process */ #define EINTR 4 /* Interrupted system call */ #define EIO 5 /* I/O error */ #define ENXIO 6 /* No such device or address */ #define E2BIG 7 /* Argument list too long */ #define ENOEXEC 8 /* Exec format error */ #define EBADF 9 /* Bad file number */ #define ECHILD 10 /* No child processes */ #define EAGAIN 11 /* Try again */ #define ENOMEM 12 /* Out of memory */ #define EACCES 13 /* Permission denied */ #define EFAULT 14 /* Bad address */ #define ENOTBLK 15 /* Block device required */ #define EBUSY 16 /* Device or resource busy */ #define EEXIST 17 /* File exists */ #define EXDEV 18 /* Cross-device link */ #define ENODEV 19 /* No such device */ #define ENOTDIR 20 /* Not a directory */ #define EISDIR 21 /* Is a directory */ #define EINVAL 22 /* Invalid argument */ #define ENFILE 23 /* File table overflow */ #define EMFILE 24 /* Too many open files */ #define ENOTTY 25 /* Not a typewriter */ #define ETXTBSY 26 /* Text file busy */ #define EFBIG 27 /* File too large */ #define ENOSPC 28 /* No space left on device */ #define ESPIPE 29 /* Illegal seek */ #define EROFS 30 /* Read-only file system */ #define EMLINK 31 /* Too many links */ #define EPIPE 32 /* Broken pipe */ #define EDOM 33 /* Math argument out of domain of func */ #define ERANGE 34 /* Math result not representable */
相关文章推荐
- 初窥Linux 之 我最常用的20条命令
- 五分钟搞定Linux容器
- 查看linux系统运行时长及重启时间
- linux下文件的读写操作(openreadwrite)
- linux 5个查找命令
- Linux服务器管理员必备Linux命令TOP5
- Linux服务器同步时间
- centos7 开机 自动连网
- Linux曲径通幽:进程管理、计划任务
- Linux曲径通幽:用户组管理
- 如何使用Linux命令行测试网速?
- linux 解压命令大全[转]
- linux ipc之匿名管道
- linux的一些常用命令和emacs的一些快捷键
- linux普通用户和超级用户之间的切换
- CentOS下安装zookeeper
- CentOS 忘记root密码的解决办法
- CentOS安装pillow报错的解决方法
- Linux服务器设置环境变量
- CentOS6.5 安装LVS+keepalived