Symbian3/SDK/Source/GUID-6CF8A41B-C2DD-5D57-A71D-6405CE08A06B.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 21 Jan 2010 18:18:20 +0000
changeset 0 89d6a7a84779
permissions -rw-r--r--
Initial contribution of Documentation_content according to Feature bug 1266 bug 1268 bug 1269 bug 1270 bug 1372 bug 1374 bug 1375 bug 1379 bug 1380 bug 1381 bug 1382 bug 1383 bug 1385

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-6CF8A41B-C2DD-5D57-A71D-6405CE08A06B"><title>Using Signals to Handle Asynchronous Events</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>You can use signals to handle asynchronous user events. A process (program code) can send a signal to itself that can be handled asynchronously based on the signal handler registered for it. This provides a way to perform tasks in parallel without any complex thread manipulation in the program code. </p> <p>The following example code demonstrates how a program code sets a signal to itself and how it handles the signal asynchronously in a signal handler: </p> <codeblock id="GUID-4424321B-112A-5556-AD29-41F613A60C84" xml:space="preserve">#include &lt;signal.h&gt;
#include &lt;stdio.h&gt;
void sighandler(int signum)
    {
    if(signum == SIGUSR1)
        {
        // Code to perform custom handling
        }
    else if(signum == SIGUSR2)
        {
        // Code to perform custom handling
        }
    }
int main()
    {
    signal(SIGUSR1,sighandler);
    signal(SIGUSR2,sighandler);
    // program logic
    raise(SIGUSR1); // indicates user event one
    // program logic
    raise(SIGUSR2); // indicates user event two
    // program logic
    return 0;
    }</codeblock> </conbody><related-links><link href="GUID-66C1493D-5B85-558A-9A39-454E6EBA307B.dita"><linktext>Signal Emulation on Symbian
                Platform</linktext> </link> <link href="GUID-186B9876-2A08-5F23-BB49-49EC34C51507.dita"><linktext>Using Signals to Terminate Processes</linktext> </link> <link href="GUID-E65D91AE-482F-5592-B83C-0F29126C2EFA.dita"><linktext>Using Signals to Handle Exceptions</linktext> </link> </related-links></concept>