system call test
Posted jingmojing
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了system call test相关的知识,希望对你有一定的参考价值。
1
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> int main(int argc, char *argv[]) { int fd = -1; int ret = 1; int buffer = 1024; int num = 0;
// O_CREAT: 当文件不存在时,创建一个新文件;O_RDWR: 以读写方式打开;O_TRUNC: 打开文件后,将文件的长度截断为0 if((fd=open("./test", O_RDWR|O_CREAT|O_TRUNC))==-1) { printf("Open Error\\n"); exit(1); } ret = write(fd, &buffer, sizeof(int)); if( ret < 0) { printf("write Error\\n"); exit(1); } printf("write %d byte(s)\\n",ret); lseek(fd, 0L, SEEK_SET); ret= read(fd, &num, sizeof(int)); if(ret==-1) { printf("read Error\\n"); exit(1); } printf("read %d byte(s),the number is %d\\n", ret, num); close(fd); return 0; }
以上是关于system call test的主要内容,如果未能解决你的问题,请参考以下文章
Futex system calls taking too much time
[工作积累] UE4 并行渲染的同步 - Sync between FParallelCommandListSet & FRHICommandListImmediate calls(代码片段
maven install报The forked VM terminated without saying properly goodbye. VM crash or System.exit call
maven install报The forked VM terminated without saying properly goodbye. VM crash or System.exit call