测试下live writer

随便写写。

#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>

int main(){
    char buffer[512];
    int n = 0;
    for(;;){
    n = read(0, buffer, sizeof(buffer));
    if(!n)
        break;
    if(n<0){
        printf("error read input\n");
        exit(-1);
    }
    if(write(1, buffer, n)!=n){
        printf("error write output\n");
        exit(-2);
    }
    
    }
    return 0;
}
posted @ 2014-12-04 15:48  MXChen  阅读(72)  评论(0)    收藏  举报