Symbian3/SDK/Source/GUID-4AEBF49C-E62A-5D0D-8181-600BF29DFFC7.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 7 51a74ef9ed63
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     1
<?xml version="1.0" encoding="utf-8"?>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     2
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     3
<!-- This component and the accompanying materials are made available under the terms of the License 
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     4
"Eclipse Public License v1.0" which accompanies this distribution, 
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     5
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     6
<!-- Initial Contributors:
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     7
    Nokia Corporation - initial contribution.
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     8
Contributors: 
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
     9
-->
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    10
<!DOCTYPE concept
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    11
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    12
<concept id="GUID-4AEBF49C-E62A-5D0D-8181-600BF29DFFC7" xml:lang="en"><title>IPC: IPC Mechanisms</title><prolog><metadata><keywords/></metadata></prolog><conbody>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    13
<p>This example demonstrates how a parent process communicates with
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    14
its child process using various IPC mechanisms. Two executables, a
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    15
parent and a child (spawned by the parent) are created to demonstrate
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    16
these mechanisms. The child process is created by the parent using
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    17
the <xref href="GUID-E7C4DE71-BC5B-34AE-ACB3-C34A0DB1FC16.dita"><apiname>posix_spawn()</apiname></xref> function. The parent process
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    18
communicates with the child process using the following IPC mechanisms: </p>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    19
<ul>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    20
<li id="GUID-D1CABBD1-AC3A-5216-B2A6-D860C876DEDE"><p>Named pipes
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    21
(FIFO - First in First Out) </p> </li>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    22
<li id="GUID-8FE87BCB-200D-5498-8F1A-851B861F8673"><p>Single pipe
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    23
(<xref href="GUID-A9DB6E7C-B8D6-377A-BBE6-39E0A7A09E5D.dita"><apiname>popen()</apiname></xref> system call) </p> </li>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    24
</ul>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    25
<section id="GUID-E584CAE4-BC05-48D5-837C-40B73DD4524F"><title>Download</title><p>Click on the following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-c5b6ac05-a3fb-45df-ab11-bd8ccc13537f.zip" scope="external">IPC.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-c5b6ac05-a3fb-45df-ab11-bd8ccc13537f.html" scope="peer">browse</xref> to view the example code. </p> </section>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    26
<section id="GUID-5513D686-D38A-49A9-B3B2-2259992A69A8"><title>Description</title> <p><b> Spawning the child process</b> </p> <p>The <xref href="GUID-E7C4DE71-BC5B-34AE-ACB3-C34A0DB1FC16.dita"><apiname>posix_spawn()</apiname></xref> function creates the child process. A pointer to the process ID
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    27
(<codeph>pid</codeph>) of the child process and the path of the child
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    28
process are passed as arguments to this function. The parent waits
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    29
for the child to terminate by calling the <xref href="GUID-8F5C89A4-7813-32C7-973E-F7F0F3690BC6.dita"><apiname>waitpid()</apiname></xref> function. </p> <p><b> Creating a named pipe</b> </p> <p>This example
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    30
creates a named pipe using the <xref href="GUID-F4749DAA-1B29-3D1D-A3AA-0D52B851E501.dita"><apiname>mkfifo()</apiname></xref> function.
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    31
The child writes data into the FIFO and then exits. The parent reads
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    32
data from FIFO and writes it to the console. The first argument of
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    33
the <xref href="GUID-F4749DAA-1B29-3D1D-A3AA-0D52B851E501.dita"><apiname>mkfifo()</apiname></xref> function indicates the path of the
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    34
FIFO file. </p> <p><b> Opening a single pipe</b> </p> <p>The parent
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    35
creates a child process and a pipe to the child process using the <xref href="GUID-A9DB6E7C-B8D6-377A-BBE6-39E0A7A09E5D.dita"><apiname>popen()</apiname></xref> function. A file handle to the pipe is returned
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    36
to the parent and the parent uses this handle to read the data written
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    37
to the pipe by the child. The path of the child process is passed
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    38
as the first argument to the <xref href="GUID-A9DB6E7C-B8D6-377A-BBE6-39E0A7A09E5D.dita"><apiname>popen()</apiname></xref> function. </p> </section>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    39
<section id="GUID-367A6465-F1C3-46B3-820B-7086E0BE1BEB"><title>Build</title> <p>The following statements are present in all the <filepath>.mmp</filepath> files of the example: </p> <codeblock id="GUID-09782F92-8B25-5CF5-8027-599685F5726D" xml:space="preserve">SYSTEMINCLUDE epoc32\include\stdapis
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    40
LIBRARY libc.lib
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    41
STATICLIBRARY libcrt0.lib</codeblock> <p> <b>Note:</b> You require
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    42
these statements because of the following reasons: </p> <ul>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    43
<li id="GUID-C735ED4D-4FDD-5535-ACA2-C645C3F10762"><p>The <filepath>epoc32\include\stdapis</filepath> directory contains header files
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    44
such as, <filepath>stdio.h</filepath>, <filepath>unistd.h</filepath> and so on that are required to build an Open Environment application. </p> </li>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    45
<li id="GUID-6351CD50-ED02-5DC9-BAAF-971CB92EEAD3"><p>The <filepath>libc.lib</filepath> file contains the definitions of all functions
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    46
that are defined in the header files associated with this example. </p> </li>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    47
<li id="GUID-C7A1D9C5-07E6-5FD1-B770-24180F04623A"><p>The <filepath>libcrt0.lib</filepath> file provides the <codeph>E32Main()</codeph> function, which is the entry point for the <codeph>main()</codeph> function of the example. </p> </li>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    48
</ul> <p> The <codeph>IPC</codeph> builds the following binaries in
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    49
the standard location (<filepath>\epoc32\release\winscw\&lt;build_variant&gt;</filepath> for Carbide.c++). </p> <ul>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    50
<li id="GUID-1F256024-8210-5C50-8B18-0498C0D5C15F"><p> <b>ipcparent.exe:</b> Executable of the parent process. </p> </li>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    51
<li id="GUID-1C755509-96FA-510A-944B-3FEA065C9936"><p> <b>ipcchild.exe:</b> Executable of the child process created using the <xref href="GUID-A9DB6E7C-B8D6-377A-BBE6-39E0A7A09E5D.dita"><apiname>popen()</apiname></xref> function. </p> </li>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    52
<li id="GUID-C056BC80-D664-5F25-A730-35220CA0A6B5"><p> <b>fifochild.exe:</b> Executable of the child process created using the <xref href="GUID-E7C4DE71-BC5B-34AE-ACB3-C34A0DB1FC16.dita"><apiname>posix_spawn()</apiname></xref> function. </p> </li>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    53
</ul> </section>
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    54
<section id="GUID-9F7DC4C5-16C8-4223-80E0-19DDF9E8303E"><title>Runtime
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    55
setting</title> <p>Two eshells must be opened before executing this
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    56
example. The executable, <filepath>ipcparent.exe</filepath> is run
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    57
in one eshell and the other eshell is used to run the child process <filepath>fifochild.exe</filepath>. You can switch between the two eshells
48780e181b38 Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 7
diff changeset
    58
by pressing <b>CTRL</b> +<b>ALT</b> +<b>SHIFT</b> +<b>T</b>. </p> </section>
7
51a74ef9ed63 Week 12 contribution of API Specs and fix SDK submission
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    59
</conbody></concept>