第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

作業(yè)社區(qū)

探索學習新天地,共享知識資源!

0 提交作業(yè)
0 布置作業(yè)
0 滿分作業(yè)
得分 100
學習任務

向佐佐 的學生作業(yè):

#include #include #include #include #include #include #include #include #define FIFO_NAME "./info" int main(void) { int ret,fd,wbytes,rbytes; int maxfd = 0; fd_set readfds,tmpfds; struct timeval tv = {3,0},tmp_tv; char buffer[64] = {0};//接收客戶端數據的buffer char rbuffer[64] = {0};//讀取管道中數據的buffer pid_t cpid; ret = access(FIFO_NAME,F_OK); if(ret != -1) { unlink(FIFO_NAME); } ret = mkfifo(FIFO_NAME,0644);//創(chuàng)建有名管道 if(ret == -1) { perror("[ERROR]mkfifo:\n"); exit(EXIT_FAILURE); } fd = open(FIFO_NAME,O_RDWR);//打開有名管道 if(fd == -1) { perror("[ERROR]open():\n"); close(fd); exit(EXIT_FAILURE); } cpid = fork();//開子進程進行有名管道數據寫入 if(cpid == -1) { perror("[ERROR]fork()\n"); return -1; } else if(cpid == 0) { printf("Please input your data:\n"); fgets(buffer,sizeof(buffer),stdin); wbytes = write(fd,buffer,strlen(buffer)); if(wbytes < 0) { perror("write():\n"); } } for(;;){ FD_ZERO(&readfds); FD_SET(fd,&readfds);// 將有名管道文件描符合集合中 tmp_tv = tv; tmpfds = readfds; ret = select(fd + 1,&tmpfds,NULL,NULL,&tmp_tv); if (ret == -1){ perror("[ERROR] select(): "); exit(EXIT_FAILURE); }else if (ret == 0){ // 超時返回 printf("Timeout.\n"); }else if (ret > 0){ if (FD_ISSET(fd,&tmpfds)){ // 判斷有名管道是否在集合中 rbytes = read(fd,rbuffer,sizeof(rbuffer)); if(rbytes

得分 100
學習任務
得分 100
學習任務

jelasin 的學生作業(yè):

#define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int main(int argc,char *argv[]) { fd_set read_fds; int pipefd[2]; if(pipe(pipefd) < 0) { perror("pipe"); return 1; } FD_ZERO(&read_fds); FD_SET(pipefd[0], &read_fds); pid_t pid = fork(); if(pid < 0) { perror("fork"); return 1; } else if(pid == 0) { close(pipefd[0]); while (true) { printf("child: waiting for input\n"); char buf[100]; read(0, buf, 100); write(pipefd[1], buf, strlen(buf)); printf("child: wrote %lu bytes: %s\n", strlen(buf), buf); if (strcmp(buf, "exit\n") == 0) { break; } } close(pipefd[1]); exit(0); } else { sleep(1); close(pipefd[1]); char buf[100]; while (true) { int ret = select(pipefd[0] + 1, &read_fds, NULL, NULL, NULL); if(ret < 0) { perror("select"); } else if(ret == 0) { printf("timeout\n"); } else { if(FD_ISSET(pipefd[0], &read_fds)) { printf("pipe is ready to read\n"); read(pipefd[0], buf, 100); printf("read %lu bytes: %s\n", strlen(buf), buf); if (strcmp(buf, "exit\n") == 0) { break; } } } } close(pipefd[0]); waitpid(pid, NULL, 0); } return 0; } ? 5 ./main child: waiting for input aaachild: wrote 3 bytes: aaa child: waiting for input pipe is ready to read read 3 bytes: aaa bbbbchild: wrote 4 bytes: bbbb child: waiting for input pipe is ready to read read 4 bytes: bbbb exit child: wrote 5 bytes: exit pipe is ready to read read 5 bytes: exit

微信客服

購課補貼
聯系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號