tstRTProcWait.cpp revision 5eabf773597082761832bc0a32b3660e8771f9f1
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * IPRT Testcase - RTProcWait.
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * available from http://www.virtualbox.org. This file is free software;
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * you can redistribute it and/or modify it under the terms of the GNU
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * General Public License (GPL) as published by the Free Software
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * The contents of this file may alternatively be used under the terms
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * of the Common Development and Distribution License Version 1.0
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * VirtualBox OSE distribution, in which case the provisions of the
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * CDDL are applicable instead of those of the GPL.
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * You may elect to license modified versions of this file under the
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * terms and conditions of either the GPL or the CDDL or both.
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync * additional information or have any questions.
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync/*******************************************************************************
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync* Header Files *
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync*******************************************************************************/
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsynctypedef struct SpawnerArgs
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync const char *pszExe;
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsyncDECLCALLBACK(int) SpawnerThread(RTTHREAD Thread, void *pvUser)
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync const char *apszArgs[3] = { pArgs->pszExe, "child", NULL };
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync return RTProcCreate(apszArgs[0], apszArgs, RTENV_DEFAULT, 0, &pArgs->Process);
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync RTPrintf("tstRTWait: spawning a child in a separate thread and waits for it in the main thread...\n");
00331fbaff118e6a5077fe96327aca51a70459dbvboxsync int rc = RTThreadCreate(&Thread, SpawnerThread, &Args, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "SPAWNER");
2ad9f8a731c73f6ac74044d42d47bbaf6f44a566vboxsync /* Wait for it to complete. */
2ad9f8a731c73f6ac74044d42d47bbaf6f44a566vboxsync int rc = RTThreadWait(Thread, RT_INDEFINITE_WAIT, &rc2);
99f33ab590a3a65e0cd082dd8d67779efb9cc6c9vboxsync /* wait for the process to complete */
a3011b448b38c39a7222f2f1eb40c8349023f650vboxsync RTPrintf("tstRTWait: Expected exit reason RTPROCEXITREASON_NORMAL, got %d.\n", Status.enmReason);
a3011b448b38c39a7222f2f1eb40c8349023f650vboxsync RTPrintf("tstRTWait: Expected exit status 42, got %d.\n", Status.iStatus);
00331fbaff118e6a5077fe96327aca51a70459dbvboxsync RTPrintf("tstRTWait: RTProcWait failed with rc=%Rrc!\n", rc);
2ad9f8a731c73f6ac74044d42d47bbaf6f44a566vboxsync RTPrintf("tstRTWait: RTThreadWait or SpawnerThread failed with rc=%Rrc!\n", rc);
a1a825a2fcd6b32bd63d40a0705ef68fcbf1ed16vboxsync RTPrintf("tstRTWait: RTThreadCreate failed with rc=%Rrc!\n", rc);