[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::c_plus_plus

Title:C++
Notice:Read 1.* and use keywords (e.g. SHOW KEY/FULL KIT_CXX_VAX_VMS)
Moderator:DECCXX::AMARTIN
Created:Fri Nov 06 1987
Last Modified:Thu Jun 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3604
Total number of notes:18242

3527.0. "alarm() w signal(SIGALRM...) does not appear to work" by CSC32::D_SANFORD () Fri Apr 04 1997 02:09

    OpenVMS Alpha V6.2, DEC C++ V5.3-005, V5.4, V5.5-017 
    OpenVMS VAX V6.0, DEC C++ T5.5-004

    The example below should set an alarm to go off in 15 seconds prior
    to sleeping for 30 seconds.  Customer claims this worked with C++
    V5.2.  Fails on VAX and Alpha, code it be the code is wrong?

    I cannot get this to work, it doesn't even return from the sleep(30).
    Is cxxl$set_condition() required here like in note 2863.* ?

    Regards, Drew Sanford
    Customer SUpport Center
    C970403-4877

/*
** $ CXX sample/except
** $ CXXLINK sample
*/
extern "C"
{
#include	<signal.h>
#include	"starlet.h"
}

#include	<fstream.h>
void alarm_action(int);
void main()
{
  signal(SIGALRM,alarm_action);
  cout<<"Go to Sleep now"<<endl;
  alarm(15);
  sleep(30);
  cout<<"We are back"<<endl;
}
void alarm_action(int x)
{
  cout<<"The alarm has fired"<<endl;
}

T.RTitleUserPersonal
Name
DateLines
3527.1why /exc on command line?HNDYMN::MCCARTHYA Quinn Martin ProductionFri Apr 04 1997 07:4915
Drew,

Compiling .0 without the /exc produces the expected results.

Adding: 
 - a call to cxx$set_condition(cxx_exception) causes the program to accvio 
   when the alarm goes off (I think this is expected since there is no 
   try/catch involved).
 - a call to cxx$set_condition(unix_signal) causes the program to work
   correctly.

Is there a reason they are using /except (ie is your simple program missing
what caused them to require it?)

Brian J.
3527.2SPECXN::DERAMODan D&#039;EramoFri Apr 04 1997 17:4716
>Adding: 
> - a call to cxx$set_condition(cxx_exception) causes the program to accvio 
>   when the alarm goes off (I think this is expected since there is no 
>   try/catch involved).
        
        It should cause the program to call terminate(), not to
        accvio.
        
>Adding: 
> - a call to cxx$set_condition(unix_signal) causes the program to work
>   correctly.

        That's interesting, as not calling cxx$set_condition at all
        should be equivalent to calling cxx$set_condition(unix_signal).
        
        Dan
3527.3CSC32::D_SANFORDFri Apr 04 1997 22:0419
    It should work with /except right?  They are using it because their
    code also includes try / catch, the code they sent is just a
    reduced version.
    
    I suggested they try:
    
      cxx$set_condition(unix_signal)
    
    as a workaround.  Hopefully this works...  This customer was not
    happy, logging every call <S1>, if this does not work I can expect
    a call every hour until it is working.  Was going to recommend he
    downgrade to V5.2, but I held back.
    
    I assume we might have two bugs here?  Not defaulting to "unix_signal"
    and alarm() not working with /except ?
    
    Thank you for the quick response.

    -drew
3527.4maybe just one but not twoHNDYMN::MCCARTHYA Quinn Martin ProductionMon Apr 07 1997 08:3721
>>    It should work with /except right?  They are using it because their

I would think so.  I'll have to check into this a little futher.


>>    as a workaround.  Hopefully this works...  This customer was not
>>    happy, logging every call <S1>, if this does not work I can expect
>>    a call every hour until it is working.  Was going to recommend he
>>    downgrade to V5.2, but I held back.

Well let us know if it does not (I'm sure you will!).  

>>    I assume we might have two bugs here?  Not defaulting to "unix_signal"
>>    and alarm() not working with /except ?

Actually, in either case, I think we only have one problem and its 
either that the default isn't occuring or that alarm() causes it to 
fail.

Brian J.

3527.5cxxl$set_condition(unix_signal) workedCSC32::D_SANFORDWed Apr 09 1997 15:325
    Good news...  the workaround appears to work!  He asked when a 
    patch would be available, but I said since there is an easy
    workaround it would only be fixed in a future release of C++.
    
    -drew
3527.6still need to check it outHNDYMN::MCCARTHYA Quinn Martin ProductionWed Apr 09 1997 19:036
>>    patch would be available, but I said since there is an easy
>>    workaround it would only be fixed in a future release of C++.

Gee - thanks !

bjm