176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * IPRT - RTSystemShutdown, linux implementation.
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * Copyright (C) 2012 Oracle Corporation
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * available from http://www.virtualbox.org. This file is free software;
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * you can redistribute it and/or modify it under the terms of the GNU
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * General Public License (GPL) as published by the Free Software
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * The contents of this file may alternatively be used under the terms
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * of the Common Development and Distribution License Version 1.0
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * VirtualBox OSE distribution, in which case the provisions of the
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * CDDL are applicable instead of those of the GPL.
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * You may elect to license modified versions of this file under the
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * terms and conditions of either the GPL or the CDDL or both.
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync/*******************************************************************************
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync* Header Files *
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync*******************************************************************************/
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsyncRTDECL(int) RTSystemShutdown(RTMSINTERVAL cMsDelay, uint32_t fFlags, const char *pszLogMsg)
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync AssertReturn(!(fFlags & ~RTSYSTEM_SHUTDOWN_VALID_MASK), VERR_INVALID_PARAMETER);
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * Assemble the argument vector.
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync apszArgs[iArg++] = "-y"; /* Pre-answer confirmation question. */
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync apszArgs[iArg++] = "-i"; /* Change to the following state. */
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync RTStrPrintf(szWhen, sizeof(szWhen), "%u", (unsigned)((cMsDelay + 499) / 1000));
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync * Start the shutdown process and wait for it to complete.
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync int rc = RTProcCreate(apszArgs[0], apszArgs, RTENV_DEFAULT, 0 /*fFlags*/, &hProc);
176e5972d88cf5575c6854860310aff1f3ddfab6vboxsync rc = RTProcWait(hProc, RTPROCWAIT_FLAGS_BLOCK, &ProcStatus);