Lines Matching refs:fd

37 static int _socketpair(int fd[2]) {
40 ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
46 static int _close(int fd) {
48 printf("%d: close(%d)\n", gettid(), fd);
49 ret = close(fd);
50 printf("%d: close(%d) = %d\n", gettid(), fd, ret);
65 printf("\tfd %d ", ufds[i].fd); print_events(ufds[i].revents);
72 static int _write(int fd, char *buf, int len) {
75 printf("%d: write(%d)\n", gettid(), fd);
76 ret = write(fd, buf, len);
77 printf("%d: write(%d) = %d\n", gettid(), fd, ret);
83 static int _read(int fd) {
87 printf("%d: read(%d)\n", gettid(), fd);
88 ret = read(fd, &buf, 1);
89 printf("%d: read(%d) = %d [%d]\n", gettid(), fd, ret, (int)buf);
95 static int _shutdown(int fd, int how) {
98 printf("%d: shutdown(%d)\n", gettid(), fd);
99 ret = shutdown(fd, how);
100 printf("%d: shutdown(%d) = %d\n", gettid(), fd, ret);
106 int fd = (int)args;
109 pfd.fd = fd;
116 int fd = (int)args;
119 pfd.fd = fd;
126 int fd = (int)args;
130 pfd.fd = fd;
138 int fd = (int)args;
140 _read(fd);
145 int fd = (int)args;
147 _close(fd);
154 int fd[2];
156 if (pipe(fd)) return -1;
163 _close(fd[1]);
172 int fd[2];
175 if (_socketpair(fd)) return -1;
177 pthread_create(&t, NULL, (void *)thread_poll, (void *)fd[1]);
181 _shutdown(fd[0], SHUT_RDWR);
185 _close(fd[0]);
193 int fd[2];
196 if (_socketpair(fd)) return -1;
198 pthread_create(&t, NULL, (void *)thread_poll, (void *)fd[0]);
202 _shutdown(fd[0], SHUT_RDWR);
206 _close(fd[0]);
214 int fd[2];
217 if (_socketpair(fd)) return -1;
219 pthread_create(&t, NULL, (void *)thread_poll, (void *)fd[0]);
223 _close(fd[0]);
231 int fd[2];
234 if (_socketpair(fd)) return -1;
236 pthread_create(&t, NULL, (void *)thread_read, (void *)fd[0]);
240 _shutdown(fd[0], SHUT_RDWR);
244 _close(fd[0]);
252 int fd[2];
256 if (pipe(fd)) {
260 printf("%d %d\n", fd[0], fd[1]);
261 close(fd[0]);
262 close(fd[1]);
270 int fd[2];
274 if (pipe(fd)) return -1;
276 pthread_create(&t1, NULL, (void *)thread_pollin, (void *)fd[0]);
277 pthread_create(&t2, NULL, (void *)thread_pollin, (void *)fd[0]);
282 _write(fd[1], &buf, 1);
293 int fd[2];
297 if (pipe(fd)) return -1;
300 pthread_create(&t[i], NULL, (void *)thread_pollin_rand_delay, (void *)fd[0]);
304 _write(fd[1], &buf, 1);
309 _close(fd[0]);
310 _close(fd[1]);
319 int fd[2];
321 if (pipe(fd)) return -1;
323 pthread_create(&t1, NULL, (void *)thread_poll, (void *)fd[0]);
324 pthread_create(&t2, NULL, (void *)thread_poll, (void *)fd[0]);
328 _shutdown(fd[1], SHUT_RDWR);
342 int fd[2];
344 if (pipe(fd)) return -1;
346 _close(fd[1]);
349 pthread_create(&t[i], NULL, (void *)thread_poll, (void *)fd[0]);
360 int fd[2];
362 if (pipe(fd)) return -1;
365 pthread_create(&t[i], NULL, (void *)thread_close, (void *)fd[i%2]);
371 int fd[2];
376 if (pipe(fd)) return -1;
377 pthread_create(&t, NULL, (void *)thread_poll, (void *)fd[0]);
378 _close(fd[1]);
379 _close(fd[0]);