Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Logging in to a UNIX System init ( Process ID 1 created by the kernel at bootstrap ) spawns getty for every terminal device invokes our login shell terminal.

Similar presentations


Presentation on theme: "1 Logging in to a UNIX System init ( Process ID 1 created by the kernel at bootstrap ) spawns getty for every terminal device invokes our login shell terminal."— Presentation transcript:

1 1 Logging in to a UNIX System init ( Process ID 1 created by the kernel at bootstrap ) spawns getty for every terminal device invokes our login shell terminal device driver user at a terminal fd 0, 1, 2 login reads password entry ( getpwnam() ), asks for user's password ( getpass() ) and validates it; changes ownership of our terminal device, changes to our UID and changes to our home directory. Sets additional environment variables ( HOME, SHELL, USER, LOGNAME, PATH ) fd 0, 1, 2 Login shell (bash) fd 0, 1, 2 getty open s terminal device, sets file descriptors 0, 1, 2 to it, waits for a user name, usually sets some environment variable ( TERM ) invokes login when user name entered

2 1 Command Execution current shell (bash) executes built-in commands (echo, kill, pwd,...) or shell scripts invoked by the. (dot) command:. shell-script sub-shell (bash) executes a shell script or calls exec() to execute a program variables defined in the parent are not passed (use the export command in parent to pass variables). Variables defined or changed in a sub-shell does not affect variables of the parent ! fork() (creates a new shell process) wait or continue if command is executed in the background sub-shell terminates after script or program execution

3 1 stack (caller info., return address, local variables) (read/write) Typical Memory Layout text (code & constants, read only) command-line arguments, environment variables initialized uninitialized Heap (dynamic memory allocation) data(read/write) char a, *p="string"; int v[10]; int f(char c) { int x, y; static long i=1;... return x; } } read from program file } initialized to 0 x, y, c p, i a, v "string", f Low address

4 1 User process Starting and Terminating a C Program UNIX kernel Program file C start-up routine main() call user functions call return exit() does not return standard I/O cleanup call return _exit() exec - the only way a program is executed by the kernel

5 1 current process sigprocmask() kernel user interrupt ( CTRL-C ) sigpending() kill() raise(), abort() process Signal Mask, Pending Signals Each process has a signal mask: set of signals currently blocked from delivery to the process signal mask can be manipulated by sigprocmask() if set is not NULL => signal mask is modified depending on the value of how if oset is not NULL => current signal mask is returned sigpending() returns the set of signals that are blocked and currently pending for the process sigset_t is a data type to represent a signal set. int sigprocmask(int how,sigset_t * set, sigset_t * oset ) int sigpending(sigset_t * set )


Download ppt "1 Logging in to a UNIX System init ( Process ID 1 created by the kernel at bootstrap ) spawns getty for every terminal device invokes our login shell terminal."

Similar presentations


Ads by Google