IceWalkers.com - Linux Software downloads and news
Name : Password :
Linux SoftwareLinux RPMLinux HowtosLink UsAboutAdvertise

sigaltstack (2)

SIGALTSTACK(2)             Linux Programmer's Manual            SIGALTSTACK(2)



NAME
       sigaltstack - set and/or get signal stack context

SYNOPSIS
       #include<signal.h>

       intsigaltstack(conststack_t*ss,stack_t*oss);

DESCRIPTION
       sigaltstack  allows  a  process  to define a new alternate signal stack
       and/or retrieve the state of an existing alternate  signal  stack.   An
       alternate signal stack is used during the execution of a signal handler
       if the establishment of that handler (see sigaction(2)) requested it.

       The normal sequence of events for using an alternate  signal  stack  is
       the following:

       1.     Allocate  an  area of memory to be used for the alternate signal
              stack.

       2.     Use sigaltstack to inform the system of the existence and  loca-
              tion of the alternate signal stack.

       3.     When  establishing  a signal handler using sigaction, inform the
              system that the signal handler should be executed on the  alter-
              nate signal stack by specifying the SA_ONSTACK flag.

       The  ss argument is used to specify a new alternate signal stack, while
       the oss argument is used to retrieve information  about  the  currently
       established  signal stack.  If we are interested in performing just one
       of these tasks then the other argument can be specified as NULL.   Each
       of these arguments is a structure of the following type:

              typedef struct {
                  void  *ss_sp;     /* Base address of stack */
                  int    ss_flags;  /* Flags */
                  size_t ss_size;   /* Number of bytes in stack */
              } stack_t;

       To  establish a new alternate signal stack, ss.ss_flags is set to zero,
       and ss.sp_sp and ss.ss_size specify the starting address  and  size  of
       the  stack.   The  constant  SIGSTKSZ  is defined to be large enough to
       cover the usual size requirements for an alternate  signal  stack,  and
       the constant MINSIGSTKSZ defines the minimum size required to execute a
       signal handler.

       To disable an existing stack, specify ss.ss_flags  as  SS_DISABLE.   In
       this case, the remaining fields in ss are ignored.

       If  oss  is  not  NULL, then it is used to return information about the
       alternate signal stack which was in effect prior to the call to sigalt-
       stack.   The  oss.ss_sp  and  oss.ss_size  fields  return  the starting
       address and size of that stack.  The oss.ss_flags may return either  of
       the following values:


       SS_ONSTACK
              The  process  is  currently  executing  on  the alternate signal
              stack.  (Note that it is not possible to  change  the  alternate
              signal stack if the process is currently executing on it.)

       SS_DISABLE
              The alternate signal stack is currently disabled.


RETURNVALUE
       sigaltstack  returns  0  on success, or -1 on failure with errno set to
       indicate the error.


ERRORS
       ENOMEM The  specified  size  of  the   new   alternate   signal   stack
              (ss.ss_size) was less than MINSTKSZ.

       EFAULT Either  ss  or  oss is not NULL and points to an area outside of
              the process's address space.

       EPERM  An attempt was made to change the alternate signal  stack  while
              it  was  active  (i.e., the process was already executing on the
              current alternate signal stack).

       EINVAL ss is not NULL and the ss_flags field contains a non-zero  value
              other than SS_DISABLE.


NOTES
       The following code segment demonstrates the use of sigaltstack:

              stack_t ss;

              ss.ss_sp = malloc(SIGSTKSZ);
              if (ss.ss_sp == NULL)
                  /* Handle error */;
              ss.ss_size = SIGSTKSZ;
              ss.ss_flags = 0;
              if (sigaltstack(&ss, NULL) == -1)
                  /* Handle error */;

       Establishing  an  alternate signal stack is useful if a process expects
       that it may exhaust its standard stack.  This may occur,  for  example,
       because  the stack grows so large that it encounters the upwardly grow-
       ing heap, or it  reaches  a  limit  established  by  a  call  to  setr-
       limit(RLIMIT_STACK,&rlim).   If  the standard stack is exhausted, the
       kernel sends the process a SIGSEGV signal.  In these circumstances  the
       only way to catch this signal is on an alternate signal stack.

       On  most  hardware  architectures supported by Linux, stacks grow down-
       wards.  sigaltstack automatically takes account  of  the  direction  of
       stack growth.

       Functions called from a signal handler executing on an alternate signal
       stack will also use the alternate signal stack.  (This also applies  to
       any  handlers  invoked for other signals while the process is executing
       on the alternate signal stack.)  Unlike the standard stack, the  system
       does  not  automatically  extend the alternate signal stack.  Exceeding
       the allocated size of the alternate signal stack will  lead  to  unpre-
       dictable results.

       A  successful  call  to  execve  removes  any existing alternate signal
       stack.

       sigaltstack supersedes the older sigstack call.  For backwards compati-
       bility,  glibc  also provides sigstack.  All new applications should be
       written using sigaltstack.


HISTORY
       BSD 4.2 had a sigstack() system call.  It  used  a  slightly  different
       struct,  and  had as major disadvantage that the caller had to know the
       direction of stack growth.


CONFORMINGTO
       SUSv2, SVr4, POSIX 1003.1-2001.


SEEALSO
       sigaction(2),  setrlimit(2),  execve(2),  sigsetjmp(3),  siglongjmp(3),
       signal(7)



Linux 2.4                         2001-09-27                    SIGALTSTACK(2)

_Exitgetsockoptoutwshmat
_exitgettidoutw_pshmctl
_llseekgettimeofdaypauseshmdt
_newselectgetuidpersonalityshmget
_sysctlgttypipeshmop
acceptidlepivot_rootshutdown
accessinbpollsigaction
acctinb_pprctlsigaltstack
adjtimexinlpreadsigblock
afs_syscallinl_pprofsiggetmask
alarminsbpselectsigmask
alloc_hugepagesinslptracesignal
arch_prctlinswpwritesigpause
bdflushintroquotactlsigpending
bindinwreadsigprocmask
breakinw_preaddirsigqueue
brkioctlreadlinksigreturn
cacheflushioctl_listreadvsigsetmask
capgetiopermrebootsigsuspend
capsetioplrecvsigtimedwait
chdiripcrecvfromsigvec
chmodkillrecvmsgsigwaitinfo
chownkillpgrenamesocket
chrootlchownrmdirsocketcall
clonelinksbrksocketpair
closelistensched_get_priority_maxssetmask
connectllseeksched_get_priority_minstat
creatlocksched_getaffinitystatfs
duplseeksched_getparamstime
dup2lstatsched_getschedulerstty
execvemadvisesched_rr_get_intervalswapoff
exitmincoresched_setaffinityswapon
fchdirmkdirsched_setparamsymlink
fchmodmknodsched_setschedulersync
fchownmlocksched_yieldsyscall
fcntlmlockallselectsyscalls
fdatasyncmmapselect_tutsysctl
flockmmap2semctlsysfs
forkmodify_ldtsemgetsysinfo
free_hugepagesmountsemopsyslog
fstatmprotectsendtime
fstatfsmpxsendfiletimes
fsyncmremapsendmsgtkill
ftruncatemsgctlsendtotruncate
futexmsggetsetcontextumask
getcontextmsgopsetdomainnameumount
getdentsmsgrcvsetegidumount2
getdomainnamemsgsndseteuiduname
getdtablesizemsyncsetfsgidundocumented
getegidmunlocksetfsuidunimplemented
geteuidmunlockallsetgidunlink
getgidmunmapsetgroupsuselib
getgroupsnanosleepsethostidustat
gethostidnfsservctlsethostnameutime
gethostnamenicesetitimerutimes
getitimerobsoletesetpgidvfork
getpagesizeoldfstatsetpgrpvhangup
getpeernameoldlstatsetpriorityvm86
getpgidoldoldunamesetregidwait
getpgrpoldstatsetresgidwait3
getpidoldunamesetresuidwait4
getppidopensetreuidwaitpid
getpriorityoutbsetrlimitwrite
getresgidoutb_psetsidwritev
getresuidoutlsetsockopt 
getrlimitoutl_psettimeofday 
getrusageoutsbsetuid 
getsidoutslsetup 


The Gimp 2.6.3
GNU Image Manipulation Program
Linux Kernel 2.6 2.6.27.7
Linux Kernel
Battle for Wesnoth 1.4.6
Fantasy Turn-Based Strategy Game
DeleGate 9.9.0-pre8
Proxy server which runs on multiple platforms
Safesquid proxy server 4.2.2.RC8.14B
Antivirus and content filtering proxy server
Thunderbird 2.0.0.18
An email and newsgroup client with powerful, new junk mail controls
Wine 1.1.9
Free implementation of Windows on Unix
WebGUI 7.5.34
A fully featured content management system.
KOffice 2.0 beta3
Integrated office suite for KDE
LimeWire 4.18.8
Gnutella Client
Free IT Magazines, White Papers, eBooks, and more !
Oracle Magazine

Contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more.

eWeek

The essential technology information source for builders of e-business.

BusinessWeek (Digital Edition)

Provides readers a deeper understanding of the trends that drive growth, and what best practices keep them ahead of the competition.

Linux Software Map
Find Linux RPM
Best Rated Linux Software
Most Rated Linux Software
Linux Distributions
Linux Howtos
Quick Survey

Please take our survey and help us improve our website to serve you better.

Thank you.
Linux Software
Linux / IT Resources
Site Resources
Google
Privacy Policy
Contact Us
Submit Software
Advertising info