javatools/javacontrolpanel/controlpanel/src/javacaptain.cpp
branchRCL_3
changeset 60 6c158198356e
equal deleted inserted replaced
59:e5618cc85d74 60:6c158198356e
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  JavaCaptain
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "com_nokia_mj_impl_javacontrolpanel_JavaCaptain.h"
       
    20 
       
    21 #ifdef __SYMBIAN32__
       
    22 #include <spawn.h>
       
    23 #else
       
    24 #include <stdio.h>
       
    25 #endif
       
    26 
       
    27 #include <cstring>
       
    28 #include <errno.h>
       
    29 #include "logger.h"
       
    30 
       
    31 /*
       
    32  * Class:     com_nokia_mj_impl_javacontrolpanel_JavaCaptain
       
    33  * Method:    _start
       
    34  * Signature: ()V
       
    35  */
       
    36 JNIEXPORT void JNICALL Java_com_nokia_mj_impl_javacontrolpanel_JavaCaptain__1start
       
    37   (JNIEnv *, jobject)
       
    38 {
       
    39     int rc = 0;
       
    40     int pid = 0;
       
    41     char* av[2];
       
    42     int index = 0;
       
    43     av[index++] = "javacaptain";
       
    44     av[index] = NULL;
       
    45 
       
    46 #ifdef __SYMBIAN32__
       
    47     rc = posix_spawn(&pid, "javacaptain", NULL, NULL, av, NULL);
       
    48 #else
       
    49     if (!(pid = fork()))
       
    50     {
       
    51         rc = execvp("javacaptain", av);
       
    52         if (rc == -1)
       
    53         {
       
    54             rc = errno;
       
    55         }
       
    56     }
       
    57 #endif // __SYMBIAN32__
       
    58 
       
    59     if (rc)
       
    60     {
       
    61         ELOG3(EUtils,"%s failed, %s - errno=%d", __PRETTY_FUNCTION__, strerror(rc), rc);
       
    62     }
       
    63 
       
    64 }
       
    65