COMP 3000 2012 Week 5 Notes: Difference between revisions
fixed link |
|||
Line 25: | Line 25: | ||
*** blocks until a child terminates | *** blocks until a child terminates | ||
** waitpid(pid_t pid, int* stat_loc, int options) | ** waitpid(pid_t pid, int* stat_loc, int options) | ||
*** blocks until child with given pid terminates | *** blocks until child with given pid (process id) terminates | ||
* process information | * process information | ||
** compare the output of strace and ltrace | ** compare the output of strace and ltrace |
Revision as of 01:37, 5 October 2012
Processes
- how a process starts
- fork()
- creates a new process
- 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