![]() |
|
||
![]() |
| Q1. Which machine does our code have to compile and run on? Faith? Trust? |
| Answer: We will run the codes on CADE lab4 machines, that is lab4-N.eng.utah.edu, where N (1-15)is the machine number. Currently Red Hat 9 runs on these machines. |
| Q2. How do we submit the project? |
| Answer: Use handin program on CADE lab machines. The basic usage is handin cs5460 project1 [your files] . |
| Q3. Is a README file required, or are good comments sufficient? |
| Answer: A README file is not necessary. However, it will help us to grade your project, and understand your code better. Codes should be commented clearly and thoroughly. |
| Q4. Should we include the concept of a path variable so that "yash: ls"> works, or should we require full path (i.e. "yash:/bin/ls" on my mac> )? |
| Answer: It depends on which exec function you use. If you use execle, you need to specific the environment. If execlp, execvp are used, these system call will duplicate the actions of the shell in searching for an executable file, if the specified file does not contain a '/'. Otherwise, the file name will be considered as a file with relative or absolute path. So, if you use execvp, you will not worry about this. |
| Q5. As far as legality is concerned with pipes and I/O redirection, is there a certain behavior our shell should have given input such as "yash: prog1 | prog2 < infile > outfile | prog3" or "yash: prog1 < infile < infile2" ? |
| Answer:The assignment does not require you to support pipes ('|'). For this you should be thankful, since it complicates things quite a bit, albeit from a fairly non-complicated starting point. In general, when it comes to handling various combinations of the required redirection operations (>, <, and >&), emulate /bin/csh or something similar. So the second example, which defines two redirections for stdin, should be flagged as an error. |
| Q6. Should my shell execute this (yash: ./prog>file) as (yash: ./prog > file)? Is "yash:./prog<file.txt" treated as valid command line ? |
| Answer: Yes. Both command lines should be valid in yash. |
| Q7. Is it all right if we have the system first check for paths, and if the path does not exist, have it check the local directory? |
| Answer: We do not need to check the validation of the execution path. If the path is incorrect, an error will occur when exec is called, and the return value of exec will be -1. Besides, the gobal variable errno will be set to indicate the error. |
| Q8. I wonder that why that lots command like ls, pwd, ... could be excuted but the cd command always is reported as no such command? It seems that I can use cp file ../ or ls ../ which may shows that there is no problem about the directory, but why cd is not recongnized? |
| Answer: It is because cd is a shell built-in
command. It is not a executable file that exists in the file system.
We can call chdir() in our shell to change directory so as to simulate
cd command. A lot of shell commands are built-in shell functions rather than Unix executables, e.g., cd, dirs, popd, pushd, and the like. If a "real" shell, in response to the cd command (after parsing doing things like expanding wildcards), the shell would change its internal view of what directory it is in. Along the same lines, things like wildcard expansion ("*", "+", etc.) are built-in shell operations. |
| Q9. The second argument to execvp is of the type char* const*. What is this! Is this a pointer to a pointer to a char? Maybe you could give me an example of something that has this type? I tried &args where args is of type char* but that didnt seem to work. |
| Answer: char * const means a constant pointer.
char * const * means a pinter to a constant poiter. Here is
a small example that can illustrate more: char * p = ...; char s[] = "Hello"; const char * pc = s; // pointer to constant pc [3] = 'g'; // * ERROR *: pc pointer to constant pc = p; // this is correct char *const cp = s; // constant pointer cp[3] = 'a'; // correct cp = p; // *ERROR*: cp is constant const char * const cpc = s; //constant pointer to constant cps[3]='a'; // ERROR cpc = p; // ERROR |
School of Computing • 50 S. Central Campus Dr. Rm.
3190 • Salt Lake City, UT 84112
801-581-8224 • Send comments to yuyang@cs.utah.edu
Disclaimer