发布时间:2014-12-04 22:22:58
int pipe(int pipefd[2]);用 pipe 创建一个管道。为什么在父子进程间使用管道需要关闭不必要的文件描述符?An application that uses pipe(2) and fork(2) should use suitable close(2) calls to close unnecessary duplicate file descriptors;this ensures that end-of-file and SIGPIPE/EPI.........【阅读全文】
发布时间:2014-11-25 22:55:19
在线程内部,私有数据可以被各个函数访问,但对其他线程是屏蔽的。一个明显的例子是errno,每个线程都有自己的副本,不然由于线程间的切换,在一个线程里输出的很可能是令一线程的出错信息。。......【阅读全文】
发布时间:2014-11-24 23:07:42
#include #include int *pa = NULL;void * fn_thread1(void * c);int main(void){ pthread_t tid; int err = 0;.........【阅读全文】
发布时间:2014-10-29 18:38:45
1. socket 的阻塞与非阻塞的含义:When the message does not fit into the send buffer of the socket, send() normally blocks, unless the socket has been placed in nonblocking I/O mode. In nonblocking mode it would fail with the error EAGAIN or EWOULDBLOCK in .........【阅读全文】
发布时间:2014-10-28 20:52:36
1. time:系统调用功能:返回从 1970-01-01 00:00:00 到此刻秒数。#include <time.h>time_t time(time_t *t);2. gettimeofday:系统调用功能:返回从 1970-01-01 00:00:00 到此刻秒数和毫秒数(比 time 返回的时间更精准)。#include <sys/time.h>int gettimeofday(struct timeval *tv, struct timezone *tz);struc.........【阅读全文】