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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

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

探索學(xué)習(xí)新天地,共享知識(shí)資源!

0 提交作業(yè)
0個(gè) 布置作業(yè)
0 滿分作業(yè)
得分 100
學(xué)習(xí)任務(wù)

SamstagBaron 的學(xué)生作業(yè):

#include #include #include #include #include #include #include #include #define FIFO_NAME "./fifo" #define MAXEVENTS 10 int main(void) { int epfd,ret; struct epoll_event ev;// 請(qǐng)求事件結(jié)構(gòu)體 struct epoll_event ret_ev[MAXEVENTS]; epfd = epoll_create(1); if (epfd == -1){ perror("[ERROR] epoll_create(): "); } printf("epfd = %d\n",epfd); pid_t pid = fork(); if(pid==-1){ perror("[ERROR] fork() : "); exit(EXIT_FAILURE); } else if(pid==0){ if(access(FIFO_NAME,F_OK)==-1) mkfifo(FIFO_NAME,0644); char wbuffer[100]={0}; int fd = open(FIFO_NAME,O_WRONLY|O_NONBLOCK); int wbytes; while(1){ fgets(wbuffer,sizeof(wbuffer),stdin); wbytes = write(fd,wbuffer,strlen(wbuffer)); if(wbuffer0){ while(access(FIFO_NAME,F_OK)==-1); int fd = open(FIFO_NAME,O_RDONLY|O_NONBLOCK); ev.data.fd = fd; // 設(shè)置文件描述符 ev.events = EPOLLIN;// 設(shè)置事件 ret = epoll_ctl(epfd,EPOLL_CTL_ADD,fd,&ev); if (ret == -1){ perror("[ERROR] epoll_ctl(): "); exit(EXIT_FAILURE); } char buffer[64] = {0}; while(1){ ret = epoll_wait(epfd,ret_ev,MAXEVENTS,1000);// 等待文件描述符關(guān)聯(lián)的事件發(fā)生 if (ret == -1){ perror("[ERROR] select(): "); exit(EXIT_FAILURE); }else if (ret == 0){ // 超時(shí)返回 printf("Timeout.\n"); }else if (ret > 0){ int rbytes; for(int i=0;i0){ buffer[rbytes]='\0'; printf(" %s",buffer); if(strncmp(buffer,"quit",4)==0){ printf("good by\n"); goto END; } } else{ perror("Read Error"); break; } } } } } } END: close(fd); } return 0; } 【圖片】

得分 100
學(xué)習(xí)任務(wù)

jelasin 的學(xué)生作業(yè):

#include #include #include #include #include #include #include #include #include #include #include #define ITERATIONS 10 void write_time_to_file(FILE *file) { time_t rawtime; struct tm *timeinfo; char buffer[80]; time(&rawtime); timeinfo = localtime(&rawtime); strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", timeinfo); fprintf(file, "%s", buffer); fflush(file); } int main() { struct sigaction sa; sa.sa_handler = SIG_IGN; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_NOCLDWAIT; sigaction(SIGCHLD, &sa, NULL); FILE *file = fopen("output.txt", "w"); if (file == NULL) { perror("fopen"); exit(EXIT_FAILURE); } sem_t *sem_parent = sem_open("/sem_parent", O_CREAT | O_EXCL, 0644, 1); sem_t *sem_child = sem_open("/sem_child", O_CREAT | O_EXCL, 0644, 0); if (sem_parent == SEM_FAILED || sem_child == SEM_FAILED) { fprintf(stderr, "sem_open failed\n"); if (errno == EEXIST) { fprintf(stderr, "Semaphore already exists\n"); if (sem_unlink("/sem_parent") < 0) { perror("sem_unlink"); exit(EXIT_FAILURE); } if (sem_unlink("/sem_child") < 0) { perror("sem_unlink"); exit(EXIT_FAILURE); } sem_t *sem_parent = sem_open("/sem_parent", O_CREAT, 0644); sem_t *sem_child = sem_open("/sem_child", O_CREAT, 0644); if (sem_trywait(sem_parent) < 0) { perror("sem_trywait"); } if (sem_trywait(sem_child) < 0) { perror("sem_trywait"); } } else { fprintf(stderr, "Error: %s\n", strerror(errno)); perror("sem_open"); sem_close(sem_parent); sem_close(sem_child); sem_unlink("/sem_parent"); sem_unlink("/sem_child"); fclose(file); exit(EXIT_FAILURE); } } pid_t pid = fork(); if (pid < 0) { perror("fork"); sem_close(sem_parent); sem_close(sem_child); sem_unlink("/sem_parent"); sem_unlink("/sem_child"); fclose(file); exit(EXIT_FAILURE); } if (pid == 0) { for (int i = 0; i < ITERATIONS; i++) { sem_wait(sem_child); sleep(1); fprintf(stderr, "Child: %d time\n", i); write_time_to_file(file); sem_post(sem_parent); } fclose(file); sem_close(sem_parent); sem_close(sem_child); exit(EXIT_SUCCESS); } else { for (int i = 1; i

微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)