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

flying_snow (飞雪浮冰)
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! :-)
(#45007@0)
2001-4-13 -05:00

回到话题: a typical unix interview question

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论

URL:   
http://www.rolia.net/zh/post.php?f=0&p=45007