Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

C/C++ API Documentation | 2025.2

# Signaler::OnIntr( SignalFunc, void * )

Register a function and argument to be called when an interrupt signal is received.

Virtual? | No |
Class | `Signaler` |
Arguments | `SignalFunc callback` | Pointer to a function to call on receipt of an interrupt signal. The function must have the prototype `voidfunc( void *ptr )`
| `void *ptr` | Pointer to a data item to pass to the callback function when invoking it.
Returns | `void` |

## Notes

Functions are called in the reverse order that they are registered.

## See also

- `Signaler::DeleteOnIntr()`

- `Signaler::Intr()`

## Example

    #include <unistd.h>     // for sleep()
    #include <stdhdrs.h>
    #include <strbuf.h>
    #include <signaler.h>

    class MyClass
    {
        public:
        void         Set( StrPtr *d ) { data = *d; }
        const StrPtr *Get()           { return &data; }
        void         Identify()       { printf( "I'm %s\n", data.Text() ); }

        private:
        StrBuf       data;
    };

    static void InterruptHandler( void *p )
    {
        MyClass      *m = ( MyClass * )p;
        m->Identify();
    }

    int main( int argc, char **argv )
    {
        for ( int i = 1; i <= 5; i++ )
        {
            StrBuf data;

            data.Set( "Object" );
            data << i;

            MyClass *p = new MyClass;
            p->Set( &data );

            signaler.OnIntr( InterruptHandler, ( void * )p );
        }

        printf( "Hit ^C to fire the interrupt handler\n" );
        for ( ; ; )
            sleep( 60 );

        exit( 0 );
    }

Your search for returned results