All pastes #402170 Raw Edit

Anonymous

public c v1 · immutable
·published 2007-03-19 19:19 UTC
rendered paste body
#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <string.h>#include <stdio.h>int main(){	int des[2];	pipe(des);		pid_t pid = fork();			if (pid == -1) {		printf("failed");		return 0;	}	else if (pid == 0) {	char x;		while (read(des[1], &x, 1)) {			printf("%c%c%c%c",x,x,x,x);		}	} else {		char xxx;		while (read(0, &xxx, 1)) {			write(des[0],  &xxx, 1);			if (xxx == 'h') break;		}	}	return 0;}