ECSE 427 Lecture Notes - Lecture 3: File Descriptor, Anonymous Pipe, Child Process

7 views3 pages
ECSE 427 Tutorial #3 Notes
Alex Hale
Fork
- split one entity into multiple similar (nearly identical) entities
- to differentiate the parent and the child after the fork:
o in the parent process, fork() returns the child process ID
o in the child process, fork() returns 0
- example: two fork() calls in one program results in four
processes being created
- variables created before the fork() call get copied into the
child
- changes to those variables after the fork() do not reflect in the
other process
- the order of execution of the parent and child process is not defined it can be either one
o if we want to, we can make the parent wait for the child to complete before executing
see waitpid()
WaitPID
Argument 1 pid_t pid
- the parent can choose to wait for a particular child to complete
o pid is the PID of that child
Argument 2 int *stat_loc
- the value pointed to indicates how the process terminated: coredump, interrupted, or signal
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents