Need help with SIGALRM/ualarm

Jeff W. Stewart jws at anaconda.cc.purdue.edu
Wed Oct 24 04:59:31 AEST 1990


In article <13211 at ogicse.ogi.edu> pturner at ese.ese.ogi.edu (Paul Turner) writes:
>
>I'm trying to do some animation on an RS6000 (a 320 w
>AIX 3.1 plus the 3001 update) and I'm having problems
>with the alarm call. The following code fragment performs
>exactly as I expected on a Sun w SunOS 4.0 but fails on the
>RS6000 with a single call to the alarm signal handler followed
>by the termination of the program. like:
>
>% testalarm
>r              <- initialize the alarm handler
>Called         <- from the handler
>Alarm call     <- from AIX !!?? and the program terminates
>
>What I believe to be the correct behavior is a continuous
>stream of 'Called' lines - as set below, every 100 milliseconds.
>This is what happens on our Suns. 
>

You're getting the SYS V style signal handling instead of the BSD style.

According to the documentation for sigaction() (which includes signal()):

      Once an action is installed for a specific signal, it remains
  installed until another action is explicitly requested (by another
  call to the sigaction subroutine), or until one of the exec subroutines
  is  called.    An  exception to  this  is  when  the SA_OLDSTYLE is set
  in which case the action of a caught signal gets set to SIG_DFL prior
  to calling the signal-catching function for that signal.

	...  ...

      The signal() in libc.a does not set SA_RESTART.  It sets the
  signal  mask  to  the signal whose action is being specified, and
  sets flags to SA_OLDSTYLE.  The BSD version of signal() sets
  SA_RESTART and preserves the current settings of
  the  signal  mask and flags.  The BSD version can be used by com-
  piling with the Berkeley Compatibility Library (libbsd.a).

And the documentation for sigset():

      Upon receipt of the signal specified by the Signal parameter,
  the  receiving process is to execute the signal catching function
  pointed to by Function.  Pending signal of this type is released.
  This address is retained across calls to the other signal manage-
  ment functions, sighold and sigrelse.  The signal number Signal
  will be passed as the only argument to the signal-catching  func-
  tion.  Before entering the signal-catching function, the value of
  Function for the caught signal will be set to SIG_HOLD.  During
  normal return from the signal-catching handler, the system signal
  action is restored to Function and any held signal of this type
  is released.  If a non-local goto (see setjmp) is taken, the
  sigrelse  subroutine must be invoked to restore the system signal
  action  and  to release any held signal of this type.

You should either load against libbsd.a or use sigset() in place of
signal().  (I tried both and they both worked)

	- Jeff Stewart



More information about the Comp.unix.aix mailing list