process-posix.cpp revision 2577367cdd717d0be1aa6f52a21ec0f562795c5f
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * IPRT - Process, POSIX.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Copyright (C) 2006-2010 Oracle Corporation
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * This file is part of VirtualBox Open Source Edition (OSE), as
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * available from http://www.virtualbox.org. This file is free software;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * you can redistribute it and/or modify it under the terms of the GNU
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * General Public License (GPL) as published by the Free Software
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Foundation, in version 2 as it comes in the "COPYING" file of the
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * The contents of this file may alternatively be used under the terms
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * of the Common Development and Distribution License Version 1.0
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * VirtualBox OSE distribution, in which case the provisions of the
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * CDDL are applicable instead of those of the GPL.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * You may elect to license modified versions of this file under the
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * terms and conditions of either the GPL or the CDDL or both.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk/*******************************************************************************
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk* Header Files *
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk*******************************************************************************/
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkRTR3DECL(int) RTProcWait(RTPROCESS Process, unsigned fFlags, PRTPROCSTATUS pProcStatus)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk do rc = RTProcWaitNoResume(Process, fFlags, pProcStatus);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkRTR3DECL(int) RTProcWaitNoResume(RTPROCESS Process, unsigned fFlags, PRTPROCSTATUS pProcStatus)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Validate input.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk AssertMsgFailed(("Invalid Process=%d\n", Process));
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk if (fFlags & ~(RTPROCWAIT_FLAGS_NOBLOCK | RTPROCWAIT_FLAGS_BLOCK))
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk AssertMsgFailed(("Invalid flags %#x\n", fFlags));
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Perform the wait.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk int rc = waitpid(Process, &iStatus, fFlags & RTPROCWAIT_FLAGS_NOBLOCK ? WNOHANG : 0);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Fill in the status structure.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk pProcStatus->enmReason = RTPROCEXITREASON_NORMAL;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk pProcStatus->enmReason = RTPROCEXITREASON_SIGNAL;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk pProcStatus->enmReason = RTPROCEXITREASON_ABEND;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Child running?
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Figure out which error to return.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkRTR3DECL(int) RTProcQueryUsername(RTPROCESS hProcess, char *pszUser, size_t cbUser,
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk AssertReturn(cbUser > 0, VERR_INVALID_PARAMETER);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk int32_t cbPwdMax = sysconf(_SC_GETPW_R_SIZE_MAX);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk int rc = getpwuid_r(geteuid(), &Pwd, pbBuf, cbPwdMax, &pPwd);