Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
<?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 <signal.h>
#include <stdio.h>
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>