Information Technology Reference
In-Depth Information
Note: You can answer this question by looking at the manual page for
fork, but before you do that, think about what the fork system call does.
If you were designing this call, would you need to allow fork to return an
error?
Note: A manual page (or \man page") is a standard way of documenting
Unix system calls and utility programs. On a Unix machine, you can access
a manual page by running the man command (e.g., manfork ). Another
way to find manual pages is via web search (e.g., search for manfork and
many of the top results will be manual pages for the fork system call.)
2. Can UNIX exec return an error? Why or why not?
Note: You can answer this question by looking at the manual page for
exec, but before you do that, think about what the exec system call does.
If you were designing this call, would you need to allow it to return an
error?
3. What happens if we run the following program on UNIX?
main(){
while(fork()>=0)
;
}
4. Explain what must happen for UNIX wait to return (successfully and)
immediately.
5. Suppose you were the instructor of a very large introductory programming
class. Explain (in English) how you would use UNIX system calls to
automate testing of submitted homework assignments.
6. What happens if you run \exec csh" in a UNIX shell? Why?
7. What happens if you run \exec ls" in a UNIX shell? Why?
8. Consider the following program:
main(intargc,char**argv){
forkthem(5)
}
voidforkthem(intn){
if(n>0){
fork();
forkthem(n-1);
}
}
How many processes are created if the above piece of code is run?
Search WWH ::




Custom Search