MUD-Dev
mailing list archive
[ Other Periods
| Other mailing lists
| Search
]
Date:
[ Previous
| Next
]
Thread:
[ Previous
| Next
]
Index:
[ Author
| Date
| Thread
]
[MUD-Dev] Re: Technical C/C++ coding question
On Sun, 14 Jun 1998 00:39:06 -0500 (CDT)
Katrina McClelan<kitkat#the486,bradley.edu> wrote:
> if(!fork()) { /* child copy starts here */
> kill(getpid(),SIGSEGV); /* this'll dump core */
> sleep(10); /* make sure it stops here */
> /* dead by here */
> }
> /* parent continues unaware */
1) No, you are not even slightly guaranteed that the child will have
fully exited/cored by the end of the sleep. Process schedulers are
funny that way. Call waitpid(). Be prepared for the child to have
already exited and to have left the process table by the time
waitpid() is run in the parent (WNOWAIT).
2) Check for failure of the fork() and retry if needed. On
healthily running systems, fork() may well fail due to contention at
the process table spinlock. The Kernel will throw an error rather
than queue the requests and guarantee success (common design decision
for SMP kernels). You should account for this.
3) You'd get slightly cleaner results if the child just immediately
hung an alarm() and the parent killed the child.
--
J C Lawrence Internet: claw#null,net
----------(*) Internet: coder#ibm,net
...Honourary Member of Clan McFud -- Teamer's Avenging Monolith...
- Thread context:
- [MUD-Dev] Re: Off topic! But please help, (continued)
[ Other Periods
| Other mailing lists
| Search
]