关于C和UNIX(MORE QUESTION)
登录 | 论坛导航 -> 华新鲜事 -> 求学狮城 | 本帖共有 7 楼,当前显示第 4 楼 : 从楼主开始阅读 : 本帖树形列表 : 返回上一页
作者:cigar (等级:2 - 初出茅庐,发帖:296) 发表:2003-11-05 14:36:21  4楼 
>>1. The parent process P creates a child process P1, then print a line. The return value of the (1st) fock() for process P1 is 0, so the second part of OR (||) is executed. As a result, P1 creates a new process P2. For P1, (fork()||fork()) is true, so the second part of AND(&&) should be executed: a new process P3 is created. For p1 the if condition is true, so p1 prints a line. For p2, fork()||fork() is false, so the if condition is false(note the 3rd fork() will not be executed), p2 doesn't execute printf statement. For p3, the 3rd fork() return 0, so the if condition is false. It skips printf statement. please correct me if i am wrong. 2. I also choose A. PID 1 : init, is the parent process of all other processes in unix. 4. For root directory, both . and .. refer to itself. so they have the same inode number. Note the parent of root is itself. If i am wrong, Please correct me
I made a mistake, i thought && and || were in
the same precedence level
Put your OWN COOL signature here!
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表

本帖共有 7 楼,当前显示第 4 楼,本文还有 N-1 层楼,要不你试试看:点击此处阅读更多 >>



请登录后回复:帐号   密码