write出錯處理

int c = write(fd, &v, sizeof(v)); if (c == -1 && errno != EINTR) { perror("Write to output file"); exit(EXIT_FAILURE); } int full_pwrite(int fd, const void *buf, size_t count, off_t offset) { size_t total = 0; for (const char *p = buf; total < count;) { ssize_t r = pwrite(fd, p+total, count-total, offset+total); if (r == -1) { if (errno != EINTR) { return r; } } else { total += r; } } return 0; }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章