What if the OS terminates the process without a call to malloc (due to
some other memory hungry process)?
What if the OS terminates the process without a call to malloc due to
some other external event (power-off)?
If a conforming process must be kept alive regardless of external
events, can an implementation ever be conforming?
The Standard describes various things that can cause program
termination: returning from the original invocation of main(),
calling exit() or _Exit() or abort(), or receiving a signal that
causes termination (there are implementation-defined aspects
here). Plus, of course, undefined behavior may include program
termination -- or even programmer termination, as illustrated
at <
http://dialspace.dial.pipex.com/town/green/gfd34/art/>.
The Standard also describes how a program executes (5.1.2.3,
also 6.8p2), and in these descriptions I see no leeway that
allows `x = y' or any such innocuous construct to terminate the
program (barring U.B., which is the program's fault and not the
implementation's worry).
The only "out" a conforming implementation can use to force
termination is to send a signal, presumably an uncatchable one
or a member of the implementation-defined set for which the
behavior is undefined if a handler attempts to return. But as
far as I can see the signal must actually be raised, even if the
root cause of termination is a bobby pin in the backplane. An
implementation that terminates a conforming program by any means
other than those documented is non-conforming; in language used
elsethread, the data-processing system "capable" of supporting
a conforming implementation has become "incapable."
In the specific case of Linux' Out-Of-Memory killer, I do
not happen to know whether it uses a signal as its murder weapon.
I also don't happen to know whether there's a "losing power"
interrupt that sends SIGPWR to every running program in the last
few milliseconds before the voltage falls too low. I sincerely
doubt the existence of SIGBOBBYPIN ...