×

Loading...

lumlum....... I have to surrender, I must fail at the interview, anyway, I want to know the right answer. :-(

about No.2:
#include "unpipc.h"
main(int argc, char **argv)
{
int fd[2], n;
char c;
pid_t childpid;

Pipe( fd );
if ( ( childpid = Fork( ) ) == 0 )
{
sleep( 3 );
if ( ( n = Read( fd[0], &c, 1 ) ) != 1 )
err_quit( "child: read returned %d", n );
printf( " child read %c\n", c);
Write( fd[0], "C", 1 )
exit( 0 );
}
Write( fd[1], "P", 1);
if ( ( n = Read( fd[1], &c, 1) ) != 1 )
err_quit( "parent: read returned %d", n );
printf( " parent read %c\n", c);
exit( 0);
}

Is it correct? Please give me a right answer, thank you! :-)
Report

Replies, comments and Discussions: