Re:In C, how do you know if the dynamic allocation succeeded?
by pjc50 on Friday November 05, 2021 @04:39PM
(#29124487)
How does Solaris handle this? Or Darwin?
[ Parent
| on HN ]
Re:In C, how do you know if the dynamic allocation succeeded?
by wahern on Friday November 05, 2021 @05:13PM
(#29124801)
Solaris has strict memory accounting; fork will fail if the system can't guarantee space for all non-shared anonymous memory. macOS has overcommit (all BSDs do to some extent, at least for fork), but it also automatically creates swap space so you rarely encounter issues one way or another in practice.
fork and malloc can also fail in Linux even with overcommit enabled (rlimits, but also OOM killer racing with I/O page dirtying triggering best-effort timeout), so Linux buys you a little convenience at the cost of making it impossibly difficult to actually guarantee behavior when it matters most.
Re:In C, how do you know if the dynamic allocation succeeded?
by scottlamb on Friday November 05, 2021 @07:36PM
(#29125868)
I don't use Solaris, but I see they have vfork [1] which should be unaffected. Likewise posix_spawn{,p}. (I think those are often implemented in userspace via vfork; unsure if there's a separate system call on Solaris.)
[1] https://docs.oracle.com/cd/E26505_01/html/816-5167/vfork-2.h...