Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 39 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
39
Dung lượng
752,93 KB
Nội dung
CS170 Operating Systems
Discussion Section
10/09/09
Issues involved with
Programming a Shell
•
•
•
•
•
Program Execution
Unix I/O
File Redirection
Pipes
Signal
Steps for shell
1. print a prompt
2. Get the command line
3. Parse the command
Command‐name [parameter] [parameter]
4. Find the file
User’s .login file
Set path=(.:/bin:/usr/bin)
5. Prepare the parameters
6. Execute the command
Fork(), execve() & wait()
Exec functions
• execl, execv, execlp, execvp
• different ways to specify the command line.
– execv() and execvp() provide argument vector
• different ways the executable is specified.
– execlp() and execvp() duplicate the actions of the
shell in searching for an executable file with path
• use execv() and/or execvp() in your shell
I/O Redirection
• Your shell must support I/O redirection for
standard input and standard output:
– cat file1
– cat file1
– cat file1