2014年12月31日
摘要:
系统调用dup和dup2能够复制文件描述符。dup返回新的文件文件描述符(没有用的文件描述符最小的编号)。dup2可以让用户指定返回的文件描述符的值,如果需要,则首先接近newfd的值,他通常用来重新打开或者重定向一个文件描述符。他的原型如下:#include int dup(int oldfd);...
阅读全文
posted @ 2014-12-31 16:37
张武亮
阅读(1099)
推荐(0)
2014年12月30日
摘要:
#include "stdio.h"#include "sys/socket.h"#include "unistd.h"int main(){ int s[2]; socketpair(AF_LOCAL, SOCK_STREAM, 0, s); int n; char buf[100]; ...
阅读全文
posted @ 2014-12-30 16:23
张武亮
阅读(251)
推荐(0)
摘要:
#include "stdio.h"#include "string.h"#include "unistd.h"#include "sys/shm.h"int main(){ int id = shmget(0x8888, 100, IPC_CREAT|0644); if (id==-1) {...
阅读全文
posted @ 2014-12-30 16:23
张武亮
阅读(250)
推荐(0)
摘要:
#include "stdio.h"#include "unistd.h"#include "pthread.h"void *func(void *p){ *(int*)p=200; int i; for (i=0; i<20; i++) { write(1, ".", 1); ...
阅读全文
posted @ 2014-12-30 16:22
张武亮
阅读(154)
推荐(0)
摘要:
介绍:od(octal dump)命令可以以八进制、十进制、十六进制和ASCII码来显示文件或者流,它们对于访问或可视地检查文件中不能直接显示在终端上的字符很有用。语法:od [-A 地址进制] [-t 显示格式] 文件选项介绍:-A 地址进制: 按指定的进制显示地址信息;-t 显示格式: 指定数据...
阅读全文
posted @ 2014-12-30 10:04
张武亮
阅读(1573)
推荐(0)
2014年12月26日
摘要:
#include "stdio.h"#include "unistd.h"#include "pthread.h"void *func(void *p){ int i; int *a=(int*)p; for (i=0; i<20; i++) { a[i]=100+i; slee...
阅读全文
posted @ 2014-12-26 15:50
张武亮
阅读(174)
推荐(0)
摘要:
#include "unistd.h"{ for(;;) { fflush(stdout); sleep(1); }{ pthread_t id; sleep(5); pthread_cancel(id); sleep(5); pthread_exit(NULL); r...
阅读全文
posted @ 2014-12-26 15:46
张武亮
阅读(157)
推荐(0)
摘要:
①匿名管道(pipe)匿名管道(pipe)管道是一种半双工的通信方式,数据只能单向流动。如果要进行双工通信,需要建立两个管道。管道只能在具有亲缘关系的进程间使用,例如父子进程或兄弟进程。②有名管道(mkfifo)有名管道也是双半工的通信方式,但它允许无亲缘关系的进程间使用。③信号量(semophor...
阅读全文
posted @ 2014-12-26 15:44
张武亮
阅读(808)
推荐(0)
摘要:
系统中能够随机(不需要按顺序)访问固定大小数据片(chunks)的设备被称作块设备,这些数据片就称作块。最常见的块设备是硬盘,除此以外,还有软盘驱动器、CD-ROM驱动器和闪存等等许多其他块设备。注意,它们都是以安装文件系统的方式使用的——这也是块设备的一般访问方式。 另一种基本的设备类型是字符设...
阅读全文
posted @ 2014-12-26 15:43
张武亮
阅读(633)
推荐(0)
2014年12月24日
摘要:
http://www.mjmwired.net/kernel/Documentation/filesystems/inotify.txthttp://www.ibm.com/developerworks/linux/library/l-ubuntu-inotify/index.html?ca=drs...
阅读全文
posted @ 2014-12-24 15:21
张武亮
阅读(1142)
推荐(0)