I took Lew Pitcher's program and gave myself the exercise of just
switching parent and child's role. Briefly, Lew Pitcher's program forks
and the child writes data to the parent, which executes less to page the >output. What you find below is my own writing of that program (with the >roles switched) --- so all errors are mine, of course.
I took Lew Pitcher's program and gave myself the exercise of just
switching parent and child's role. Briefly, Lew Pitcher's program forks
and the child writes data to the parent, which executes less to page the output. What you find below is my own writing of that program (with the roles switched) --- so all errors are mine, of course.
I think this program is wrong because the parent doesn't wait for the
child, so the child finishes ``quickly'' and must be left in a zombie
state until less exits. When less exits, it does so without calling
wait(), so the child ends up being wait()ed by the init program. Things might end up well, but it's a totally flawed design.
That's my understanding. I appreciate if you correct any
misunderstandings here. Thank you.
Meredith Montgomery <mmontgomery@levado.to> writes:
I took Lew Pitcher's program and gave myself the exercise of just
switching parent and child's role. Briefly, Lew Pitcher's program forks >>and the child writes data to the parent, which executes less to page the >>output. What you find below is my own writing of that program (with the >>roles switched) --- so all errors are mine, of course.
Keep in mind that there is no guarantee as to whether the child
process runs before the parent, or that the parent runs before the
child, or that they don't run _at the same time_ (e.g. on a multicore processor). In this case, the child could have run to completion before
the parent returns from the fork() system call.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 493 |
Nodes: | 16 (2 / 14) |
Uptime: | 04:53:36 |
Calls: | 9,709 |
Calls today: | 4 |
Files: | 13,740 |
Messages: | 6,181,031 |