User Details
- User Since
- Nov 5 2015, 11:28 PM (468 w, 2 d)
Nov 19 2015
Hi mjg,
Diff2 ID:10314 and Diff 3 ID:10315 provide alternative solutions to eliminate abort() in popen() along the lines of your thought.
popen() attempts to allocate resources (memory, file stream) before child creation.
Modifications focus on minimum resources and apply to a couple of lines in parent.
Nov 12 2015
Hi mjg,
Here we are hitting the case of resource limits getting exhausted (max file streams opened hits the ceiling). Following are the options we can take to solve the problem:
- It is conventional practice to generate exception like abort() in software indicating there is something critically wrong so that the issue can be debugged at the earliest.
- Check for failures, undo things already done in the function path (close files, free memory, etc.,.) and return error. In such cases, the system
may end up with side-effect problems or exit indicating error. It may not be possible to undo all things. This increases complexity.
Option 1 is preferable since it keeps things simple.
Nov 11 2015
Check is added for fdopen() returning NULL and corresponding error message emitted through perror() followed by abort() exception generation.