Shell Flashcards
1
Q
Shell
A
- started automatically by unix after login
- Allows the user to interactively start, stop, suspend, and resume
other programs and control the access of programs to the terminal - Supports automation by executing files of commands (“shell scripts”), provides programming language constructs (variables, string expressions, conditional branches, loops, concurrency)
- Select files with fewer keystrokes [Simplifies file selection via keyboard (regular expressions, file name completion)]
- Simplify command entry – Simplifies entry of command arguments with editing and history functions
- Most common shell – Most common shell (“sh”) developed 1975 by Stephen Bourne, modern GNU replacement is “bash” (“Bourne-Again SHell”)
2
Q
Unix IPC - supported by shell, via command line syntax
A
Process A -> B (provided into process) - Invoke - provide command line args - environment vars - current directory - signals - resource limits, umask - priority (out of process) - return value - ability to have execution completion time queried (duplex) - standard input / out / err - files/pipes
3
Q
UNIX IPC not supported by shell
A
Full duplex:
- sockets
- shared memory
- semaphores
- messages
4
Q
Receiving/returning communication channels in a C program
A
- C program invoked
- OS calls main function, recieves argv array, plus a global variable environ, which is a name of strings of the form name=value where name is free of =.
- argv[0] is usually the name or path of the program
- main() == 0 signals success, other values signal errors to calling process
5
Q
Unix file IO
A
- open() or creat() system calls taking a path name, returning an integer “file descriptor”
- read()/write()/seek() system calls, taking FD as an operand
- close() to release any data structures associated with an opened file (position pointer, buffers, etc.)
6
Q
view currently opened files
A
lsof tool
7
Q
Standard file descriptors
A
Shell opens three FDs for each process - 0 = standard input [=keyboard] - 1 = standard output - 2= standard error [both=screen of video terminal]