COMP 3000 2012 Week 5 Notes
Processes
- how a process starts
- fork()
- creates a new process
- creates own distinct address space
- different return values for parent and child
- copies state, doesn't share
- modern unix doesn't actually copy, it just pretends that it copies
- "[...] which is the story of virtual memory." -Anil
- execve(const char *path, char *const argv[], char *const envp[])
- when a process runs execve, it commits suicide and hands its process over to the new execution
- note that the arrays themselves are null terminated
- copies state, doesn't share
- envp are environment variables
- file descriptors stay open
- so if you redirect file descriptors for original process, they stay redirected
- env
- command that dumps environment variables
- fork()
- how a process ends
- exit(int return)
- zero is normal exit
- non-zero is abnormal
- magic! see: source for exit(int) in minix
- wait(int* stat_loc)
- blocks until a child terminates
- waitpid(pid_t pid, int* stat_loc, int options)
- blocks until child with given pid (process id) terminates
- exit(int return)
- process information
- compare the output of strace and ltrace
- tells you what the library is doing before it gets to the system level
- compare the output of strace and ltrace
- system calls
- open
- creates a file descriptor
- close
- read
- write
- seek
- chown
- the chgrp command uses the lchown system call
- chmod
- unlink
- mmap
- map to memory
- forward reference to the story of virtual memory
- open