Chapter Contents

Previous

Next
SIGMEM

SIGMEM



No Memory Available for Stack Space


Default handling
Ignoring the signal
Information returned by siginfo
Notes on defining a handler
The SIGMEM signal is raised when a function call requires additional stack space, but little space is available. At the start of program execution, 4K of stack space is reserved for emergency use; when no other space is available, the SIGMEM signal is raised. The reserved stack space is available to ensure that you can still execute a handler for the SIGMEM signal.

Note:    If you use the =minimal run-time option to suppress stack overflow checking, the SIGMEM signal does not occur. In this case, if you run out of stack space, your program will probably ABEND as it tries to write past the end of the stack.  [cautionend]


Default handling

The default handling for the SIGMEM signal is to ignore the condition. If the program can finish executing in the 4K of stack space reserved for emergency use, the program completes normally. If the program requires more than the emergency allocation, the program abnormally terminates with an 80A ABEND in OS/390 or a 0F7 in CMS.


Ignoring the signal

If your program ignores SIGMEM , processing proceeds as described in the SIGMEM section Default handling.


Information returned by siginfo

If you call siginfo after a SIGMEM signal occurs, siginfo returns a pointer to an integer that contains the number of bytes required. This is only an approximation, and there is no guarantee that freeing this amount of memory will permit the failed allocation to succeed.


Notes on defining a handler

Because a SIGMEM handler is called when there is little memory available, you should avoid using any functions that require large amounts of memory. In particular, avoid opening files in a SIGMEM handler. You also should avoid output to stdout or stderr , unless these files have been used because these files are only partially open until they are first used. If you want to handle SIGMEM by writing an error message and terminating and you cannot guarantee that you have already used the diagnostic file, use longjmp to exit from the handler and write the message on completion of the jump. Termination of intermediate routines by longjmp may cause additional stack space to become available.

If the handler for SIGMEM returns to the point of interrupt, another attempt is made to allocate more stack space. If this attempt fails, the emergency allocation is used if less than 4K is required. If the emergency space is not sufficient, the program abnormally terminates.

After SIGMEM is raised during a program's execution, it is not raised again until one or more stack allocations have been successfully performed. This avoids the possibility of endless loops in which SIGMEM is raised repeatedly.


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.