Index: /trunk/src/VBox/Main/include/DHCPServerImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/DHCPServerImpl.h	(revision 79643)
+++ /trunk/src/VBox/Main/include/DHCPServerImpl.h	(revision 79644)
@@ -23,4 +23,5 @@
 
 #include "DHCPServerWrap.h"
+#include <map>
 
 namespace settings
@@ -31,27 +32,4 @@
 }
 
-
-#ifdef VBOX_WITH_HOSTNETIF_API
-struct NETIFINFO;
-#endif
-
-#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
-# define DHCP_EXECUTABLE_NAME "VBoxNetDHCP.exe"
-#else
-# define DHCP_EXECUTABLE_NAME "VBoxNetDHCP"
-#endif
-
-class DHCPServerRunner : public NetworkServiceRunner
-{
-public:
-    DHCPServerRunner() : NetworkServiceRunner(DHCP_EXECUTABLE_NAME) {}
-    virtual ~DHCPServerRunner() {};
-
-    static const std::string kDsrKeyGateway;
-    static const std::string kDsrKeyLowerIp;
-    static const std::string kDsrKeyUpperIp;
-    static const std::string kDsrKeyConfig;
-    static const std::string kDsrKeyComment;
-};
 
 /**
@@ -67,5 +45,4 @@
  *  the middle.
  */
-
 class ATL_NO_VTABLE DHCPServer
     : public DHCPServerWrap
@@ -86,12 +63,9 @@
     // Public internal methids.
     HRESULT i_saveSettings(settings::DHCPServer &data);
-    settings::DhcpOptionMap &i_findOptMapByVmNameSlot(const com::Utf8Str &aVmName,
-                                                      LONG Slot);
+    settings::DhcpOptionMap &i_findOptMapByVmNameSlot(const com::Utf8Str &aVmName, LONG Slot);
 
 private:
-    HRESULT encodeOption(com::Utf8Str &aEncoded,
-                         uint32_t aOptCode, const settings::DhcpOptValue &aOptValue);
-    int addOption(settings::DhcpOptionMap &aMap,
-                  DhcpOpt_T aOption, const com::Utf8Str &aValue);
+    HRESULT encodeOption(com::Utf8Str &aEncoded, uint32_t aOptCode, const settings::DhcpOptValue &aOptValue);
+    int addOption(settings::DhcpOptionMap &aMap, DhcpOpt_T aOption, const com::Utf8Str &aValue);
 
     // wrapped IDHCPServer properties
Index: /trunk/src/VBox/Main/include/NetworkServiceRunner.h
===================================================================
--- /trunk/src/VBox/Main/include/NetworkServiceRunner.h	(revision 79643)
+++ /trunk/src/VBox/Main/include/NetworkServiceRunner.h	(revision 79644)
@@ -22,17 +22,20 @@
 #endif
 
-#include <iprt/err.h>
-#include <iprt/types.h>
-#include <iprt/string.h>
-#include <iprt/mem.h>
 #include <VBox/com/string.h>
 
-#include <string>
 
+/** @name Internal networking trunk type option values (NetworkServiceRunner::kpszKeyTrunkType)
+ *  @{ */
 #define TRUNKTYPE_WHATEVER "whatever"
 #define TRUNKTYPE_NETFLT   "netflt"
 #define TRUNKTYPE_NETADP   "netadp"
 #define TRUNKTYPE_SRVNAT   "srvnat"
+/** @} */
 
+/**
+ * Network service runner.
+ *
+ * Build arguments, starts and stops network service processes.
+ */
 class NetworkServiceRunner
 {
@@ -41,20 +44,26 @@
     virtual ~NetworkServiceRunner();
 
-    int setOption(const std::string& key, const std::string& val);
-    void clearOptions();
+    /** @name Argument management
+     * @{ */
+    int  addArgument(const char *pszArgument);
+    int  addArgPair(const char *pszOption, const char *pszValue);
+    void resetArguments();
+    /** @} */
 
-    int  start(bool aKillProcOnStop);
+    int  start(bool aKillProcessOnStop);
     int  stop();
     bool isRunning();
     void detachFromServer();
 
-    static const std::string kNsrKeyName;
-    static const std::string kNsrKeyNetwork;
-    static const std::string kNsrKeyTrunkType;
-    static const std::string kNsrTrunkName;
-    static const std::string kNsrMacAddress;
-    static const std::string kNsrIpAddress;
-    static const std::string kNsrIpNetmask;
-    static const std::string kNsrKeyNeedMain;
+    /** @name Common options
+     * @{ */
+    static const char * const kpszKeyNetwork;
+    static const char * const kpszKeyTrunkType;
+    static const char * const kpszTrunkName;
+    static const char * const kpszMacAddress;
+    static const char * const kpszIpAddress;
+    static const char * const kpszIpNetmask;
+    static const char * const kpszKeyNeedMain;
+    /** @} */
 
 private:
Index: /trunk/src/VBox/Main/src-server/DHCPServerImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/DHCPServerImpl.cpp	(revision 79643)
+++ /trunk/src/VBox/Main/src-server/DHCPServerImpl.cpp	(revision 79644)
@@ -16,4 +16,8 @@
  */
 
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
 #define LOG_GROUP LOG_GROUP_MAIN_DHCPSERVER
 #include "NetworkServiceRunner.h"
@@ -23,4 +27,5 @@
 
 #include <iprt/asm.h>
+#include <iprt/err.h>
 #include <iprt/file.h>
 #include <iprt/net.h>
@@ -35,14 +40,45 @@
 #include "VirtualBoxImpl.h"
 
-// constructor / destructor
-/////////////////////////////////////////////////////////////////////////////
-/** @todo Convert to C strings as this is wastefull:    */
-const std::string DHCPServerRunner::kDsrKeyGateway = "--gateway";
-const std::string DHCPServerRunner::kDsrKeyLowerIp = "--lower-ip";
-const std::string DHCPServerRunner::kDsrKeyUpperIp = "--upper-ip";
-const std::string DHCPServerRunner::kDsrKeyConfig  = "--config";
-const std::string DHCPServerRunner::kDsrKeyComment = "--comment";
-
-
+
+/*********************************************************************************************************************************
+*   Defined Constants And Macros                                                                                                 *
+*********************************************************************************************************************************/
+#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
+# define DHCP_EXECUTABLE_NAME "VBoxNetDHCP.exe"
+#else
+# define DHCP_EXECUTABLE_NAME "VBoxNetDHCP"
+#endif
+
+
+/**
+ * DHCP server specialization of NetworkServiceRunner.
+ *
+ * Just defines the executable name and adds option constants.
+ */
+class DHCPServerRunner : public NetworkServiceRunner
+{
+public:
+    DHCPServerRunner() : NetworkServiceRunner(DHCP_EXECUTABLE_NAME)
+    {}
+    virtual ~DHCPServerRunner()
+    {}
+
+    static const char * const kDsrKeyGateway;
+    static const char * const kDsrKeyLowerIp;
+    static const char * const kDsrKeyUpperIp;
+    static const char * const kDsrKeyConfig;
+    static const char * const kDsrKeyComment;
+};
+
+/*static*/ const char * const DHCPServerRunner::kDsrKeyGateway = "--gateway";
+/*static*/ const char * const DHCPServerRunner::kDsrKeyLowerIp = "--lower-ip";
+/*static*/ const char * const DHCPServerRunner::kDsrKeyUpperIp = "--upper-ip";
+/*static*/ const char * const DHCPServerRunner::kDsrKeyConfig  = "--config";
+/*static*/ const char * const DHCPServerRunner::kDsrKeyComment = "--comment";
+
+
+/**
+ * Hidden private data of the DHCPServer class.
+ */
 struct DHCPServer::Data
 {
@@ -51,5 +87,5 @@
         , router(false)
     {
-        tempConfigFileName[0] = '\0';
+        szTempConfigFileName[0] = '\0';
     }
 
@@ -65,5 +101,5 @@
     settings::VmSlot2OptionsMap VmSlot2Options;
 
-    char tempConfigFileName[RTPATH_MAX];
+    char szTempConfigFileName[RTPATH_MAX];
     com::Utf8Str strLeasesFilename;
     com::Utf8Str networkName;
@@ -73,7 +109,11 @@
 
 
+// constructor / destructor
+/////////////////////////////////////////////////////////////////////////////
+
+
 DHCPServer::DHCPServer()
-  : m(NULL)
-  , mVirtualBox(NULL)
+    : m(NULL)
+    , mVirtualBox(NULL)
 {
     m = new DHCPServer::Data();
@@ -144,6 +184,5 @@
 
 
-HRESULT DHCPServer::init(VirtualBox *aVirtualBox,
-                         const settings::DHCPServer &data)
+HRESULT DHCPServer::init(VirtualBox *aVirtualBox, const settings::DHCPServer &data)
 {
     /* Enclose the state transition NotReady->InInit->Ready */
@@ -161,10 +200,8 @@
 
     m->GlobalDhcpOptions.clear();
-    m->GlobalDhcpOptions.insert(data.GlobalDhcpOptions.begin(),
-                               data.GlobalDhcpOptions.end());
+    m->GlobalDhcpOptions.insert(data.GlobalDhcpOptions.begin(), data.GlobalDhcpOptions.end());
 
     m->VmSlot2Options.clear();
-    m->VmSlot2Options.insert(data.VmSlot2OptionsM.begin(),
-                            data.VmSlot2OptionsM.end());
+    m->VmSlot2Options.insert(data.VmSlot2OptionsM.begin(), data.VmSlot2OptionsM.end());
 
     autoInitSpan.setSucceeded();
@@ -700,5 +737,5 @@
         return hrc;
 
-    m->dhcp.clearOptions(); /* (Not DHCP options, but command line options for the service) */
+    m->dhcp.resetArguments();
 
 #ifdef VBOX_WITH_DHCPD
@@ -708,12 +745,12 @@
      */
     /** @todo put this next to the leases file.   */
-    int rc = RTPathTemp(m->tempConfigFileName, sizeof(m->tempConfigFileName));
+    int rc = RTPathTemp(m->szTempConfigFileName, sizeof(m->szTempConfigFileName));
     if (RT_SUCCESS(rc))
-        rc = RTPathAppend(m->tempConfigFileName, sizeof(m->tempConfigFileName), "dhcp-config-XXXXX.xml");
+        rc = RTPathAppend(m->szTempConfigFileName, sizeof(m->szTempConfigFileName), "dhcp-config-XXXXX.xml");
     if (RT_SUCCESS(rc))
-        rc = RTFileCreateTemp(m->tempConfigFileName, 0600);
+        rc = RTFileCreateTemp(m->szTempConfigFileName, 0600);
     if (RT_FAILURE(rc))
     {
-        m->tempConfigFileName[0] = '\0';
+        m->szTempConfigFileName[0] = '\0';
         return E_FAIL;
     }
@@ -791,21 +828,19 @@
 
     xml::XmlFileWriter writer(doc);
-    writer.write(m->tempConfigFileName, false);
-
-    m->dhcp.setOption(DHCPServerRunner::kDsrKeyConfig, m->tempConfigFileName);    /* command line options, not dhcp ones. */
-    m->dhcp.setOption(DHCPServerRunner::kDsrKeyComment, m->networkName.c_str());
+    writer.write(m->szTempConfigFileName, false);
+
+    m->dhcp.addArgPair(DHCPServerRunner::kDsrKeyConfig, m->szTempConfigFileName);
+    m->dhcp.addArgPair(DHCPServerRunner::kDsrKeyComment, m->networkName.c_str());
 
 #else /* !VBOX_WITH_DHCPD */
     /* Main is needed for NATNetwork */
     if (m->router)
-        m->dhcp.setOption(NetworkServiceRunner::kNsrKeyNeedMain, "on");
+        m->dhcp.addArgPair(NetworkServiceRunner::kpszKeyNeedMain, "on");
 
     /* Commmon Network Settings */
-    m->dhcp.setOption(NetworkServiceRunner::kNsrKeyNetwork, aNetworkName.c_str());
-
+    m->dhcp.addArgPair(NetworkServiceRunner::kpszKeyNetwork, aNetworkName.c_str());
     if (!aTrunkName.isEmpty())
-        m->dhcp.setOption(NetworkServiceRunner::kNsrTrunkName, aTrunkName.c_str());
-
-    m->dhcp.setOption(NetworkServiceRunner::kNsrKeyTrunkType, aTrunkType.c_str());
+        m->dhcp.addArgPair(NetworkServiceRunner::kpszTrunkName, aTrunkName.c_str());
+    m->dhcp.addArgPair(NetworkServiceRunner::kpszKeyTrunkType, aTrunkType.c_str());
 
     /* XXX: should this MAC default initialization moved to NetworkServiceRunner? */
@@ -814,12 +849,10 @@
     guid.create();
     RTStrPrintf (strMAC, sizeof(strMAC), "08:00:27:%02X:%02X:%02X",
-                 guid.raw()->au8[0],
-                 guid.raw()->au8[1],
-                 guid.raw()->au8[2]);
-    m->dhcp.setOption(NetworkServiceRunner::kNsrMacAddress, strMAC);
-    m->dhcp.setOption(NetworkServiceRunner::kNsrIpAddress,  Utf8Str(m->IPAddress).c_str());
-    m->dhcp.setOption(NetworkServiceRunner::kNsrIpNetmask, Utf8Str(m->GlobalDhcpOptions[DhcpOpt_SubnetMask].text).c_str());
-    m->dhcp.setOption(DHCPServerRunner::kDsrKeyLowerIp, Utf8Str(m->lowerIP).c_str());
-    m->dhcp.setOption(DHCPServerRunner::kDsrKeyUpperIp, Utf8Str(m->upperIP).c_str());
+                 guid.raw()->au8[0], guid.raw()->au8[1], guid.raw()->au8[2]);
+    m->dhcp.addArgPair(NetworkServiceRunner::kpszMacAddress, strMAC);
+    m->dhcp.addArgPair(NetworkServiceRunner::kpszIpAddress, m->IPAddress.c_str());
+    m->dhcp.addArgPair(NetworkServiceRunner::kpszIpNetmask, m->GlobalDhcpOptions[DhcpOpt_SubnetMask].text.c_str());
+    m->dhcp.addArgPair(DHCPServerRunner::kDsrKeyLowerIp, m->lowerIP.c_str());
+    m->dhcp.addArgPair(DHCPServerRunner::kDsrKeyUpperIp, m->upperIP.c_str());
 #endif /* !VBOX_WITH_DHCPD */
 
@@ -830,11 +863,11 @@
 
 
-HRESULT DHCPServer::stop (void)
+HRESULT DHCPServer::stop(void)
 {
 #ifdef VBOX_WITH_DHCPD
-    if (m->tempConfigFileName[0])
-    {
-        RTFileDelete(m->tempConfigFileName);
-        m->tempConfigFileName[0] = 0;
+    if (m->szTempConfigFileName[0])
+    {
+        RTFileDelete(m->szTempConfigFileName);
+        m->szTempConfigFileName[0] = 0;
     }
 #endif /* VBOX_WITH_DHCPD */
Index: /trunk/src/VBox/Main/src-server/NATNetworkImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/NATNetworkImpl.cpp	(revision 79643)
+++ /trunk/src/VBox/Main/src-server/NATNetworkImpl.cpp	(revision 79644)
@@ -760,8 +760,8 @@
     AssertReturn(!m->s.strNetworkName.isEmpty(), E_FAIL);
 
-    m->NATRunner.setOption(NetworkServiceRunner::kNsrKeyNetwork, Utf8Str(m->s.strNetworkName).c_str());
-    m->NATRunner.setOption(NetworkServiceRunner::kNsrKeyTrunkType, Utf8Str(aTrunkType).c_str());
-    m->NATRunner.setOption(NetworkServiceRunner::kNsrIpAddress, Utf8Str(m->IPv4Gateway).c_str());
-    m->NATRunner.setOption(NetworkServiceRunner::kNsrIpNetmask, Utf8Str(m->IPv4NetworkMask).c_str());
+    m->NATRunner.addArgPair(NetworkServiceRunner::kpszKeyNetwork, Utf8Str(m->s.strNetworkName).c_str());
+    m->NATRunner.addArgPair(NetworkServiceRunner::kpszKeyTrunkType, Utf8Str(aTrunkType).c_str());
+    m->NATRunner.addArgPair(NetworkServiceRunner::kpszIpAddress, Utf8Str(m->IPv4Gateway).c_str());
+    m->NATRunner.addArgPair(NetworkServiceRunner::kpszIpNetmask, Utf8Str(m->IPv4NetworkMask).c_str());
 
     /* No portforwarding rules from command-line, all will be fetched via API */
Index: /trunk/src/VBox/Main/src-server/NetworkServiceRunner.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/NetworkServiceRunner.cpp	(revision 79643)
+++ /trunk/src/VBox/Main/src-server/NetworkServiceRunner.cpp	(revision 79644)
@@ -20,13 +20,12 @@
 *   Header Files                                                                                                                 *
 *********************************************************************************************************************************/
-#include <map>
-#include <string>
 #include "NetworkServiceRunner.h"
 
+#include <iprt/env.h>
+#include <iprt/err.h>
+#include <iprt/log.h>
 #include <iprt/process.h>
 #include <iprt/path.h>
 #include <iprt/param.h>
-#include <iprt/env.h>
-#include <iprt/log.h>
 #include <iprt/thread.h>
 
@@ -35,13 +34,11 @@
 *   Global Variables                                                                                                             *
 *********************************************************************************************************************************/
-/** @todo Convert to C strings as this is wastefull:    */
-const std::string NetworkServiceRunner::kNsrKeyName      = "--name";
-const std::string NetworkServiceRunner::kNsrKeyNetwork   = "--network";
-const std::string NetworkServiceRunner::kNsrKeyTrunkType = "--trunk-type";
-const std::string NetworkServiceRunner::kNsrTrunkName    = "--trunk-name";
-const std::string NetworkServiceRunner::kNsrMacAddress   = "--mac-address";
-const std::string NetworkServiceRunner::kNsrIpAddress    = "--ip-address";
-const std::string NetworkServiceRunner::kNsrIpNetmask    = "--netmask";
-const std::string NetworkServiceRunner::kNsrKeyNeedMain  = "--need-main";
+/*static*/ const char * const NetworkServiceRunner::kpszKeyNetwork   = "--network";
+/*static*/ const char * const NetworkServiceRunner::kpszKeyTrunkType = "--trunk-type";
+/*static*/ const char * const NetworkServiceRunner::kpszTrunkName    = "--trunk-name";
+/*static*/ const char * const NetworkServiceRunner::kpszMacAddress   = "--mac-address";
+/*static*/ const char * const NetworkServiceRunner::kpszIpAddress    = "--ip-address";
+/*static*/ const char * const NetworkServiceRunner::kpszIpNetmask    = "--netmask";
+/*static*/ const char * const NetworkServiceRunner::kpszKeyNeedMain  = "--need-main";
 
 
@@ -49,16 +46,49 @@
 *   Structures and Typedefs                                                                                                      *
 *********************************************************************************************************************************/
+/**
+ * Internal data the rest of the world does not need to be bothered with.
+ *
+ * @note no 'm' prefix here, as the runner is accessing it thru an 'm' member.
+ */
 struct NetworkServiceRunner::Data
 {
+    /** The process filename. */
+    const char *pszProcName;
+    /** Actual size of papszArgs. */
+    size_t      cArgs;
+    /** Number of entries allocated for papszArgs.  */
+    size_t      cArgsAlloc;
+    /** The argument vector.
+     * Each entry is a string allocation via RTStrDup.  The zero'th entry is
+     * filled in by start(). */
+    char      **papszArgs;
+    /** The process ID. */
+    RTPROCESS   Process;
+    /** Whether to kill the process on stopping.   */
+    bool        fKillProcessOnStop;
+
     Data(const char* aProcName)
-        : mProcName(aProcName)
-        , mProcess(NIL_RTPROCESS)
-        , mKillProcOnStop(false)
+        : pszProcName(aProcName)
+        , cArgs(0)
+        , cArgsAlloc(0)
+        , papszArgs(NULL)
+        , Process(NIL_RTPROCESS)
+        , fKillProcessOnStop(false)
     {}
-    const char *mProcName;
-    RTPROCESS mProcess;
-    std::map<std::string, std::string> mOptions; /**< @todo r=bird: A map for command line option/value pairs? really?
-                                                  * Wouldn't a simple argument list have done it much much more efficiently? */
-    bool mKillProcOnStop;
+
+    ~Data()
+    {
+        resetArguments();
+    }
+
+    void resetArguments()
+    {
+        for (size_t i = 0; i < cArgs; i++)
+            RTStrFree(papszArgs[i]);
+        RTMemFree(papszArgs);
+        cArgs = 0;
+        cArgsAlloc = 0;
+        papszArgs = NULL;
+    }
 };
 
@@ -79,14 +109,65 @@
 
 
-int NetworkServiceRunner::setOption(const std::string& key, const std::string& val)
-{
-    m->mOptions.insert(std::map<std::string, std::string>::value_type(key, val));
-    return VINF_SUCCESS;
-}
-
-
-void NetworkServiceRunner::clearOptions()
-{
-    m->mOptions.clear();
+/**
+ * Adds one argument to the server command line.
+ *
+ * @returns IPRT status code.
+ * @param   pszArgument         The argument to add.
+ */
+int NetworkServiceRunner::addArgument(const char *pszArgument)
+{
+    AssertPtr(pszArgument);
+
+    /*
+     * Grow the argument vector as needed.
+     * Make sure unused space is NULL'ed and that we've got an extra entry for
+     * the NULL terminator.  Arguments starts at 1 of course, 0 being the executable.
+     */
+    size_t const i      = RT_MAX(m->cArgs, 1);
+    size_t const cAlloc = m->cArgsAlloc;
+    if (i + 1 /*NULL terminator*/ >= m->cArgsAlloc)
+    {
+        size_t cNewAlloc = cAlloc ? cAlloc : 2;
+        do
+            cNewAlloc *= 2;
+        while (cNewAlloc <= i + 1);
+        void *pvNew = RTMemRealloc(m->papszArgs, cNewAlloc * sizeof(m->papszArgs[0]));
+        AssertReturn(pvNew, VERR_NO_MEMORY);
+        m->papszArgs = (char **)pvNew;
+        RT_BZERO(&m->papszArgs[m->cArgsAlloc], (cNewAlloc - cAlloc) * sizeof(m->papszArgs[0]));
+        m->cArgsAlloc = cNewAlloc;
+    }
+
+    /*
+     * Add it.
+     */
+    m->papszArgs[i] = RTStrDup(pszArgument);
+    if (m->papszArgs[i])
+    {
+        m->cArgs = i + 1;
+        Assert(m->papszArgs[m->cArgs] == NULL);
+        return VINF_SUCCESS;
+    }
+    return VERR_NO_STR_MEMORY;
+}
+
+
+/**
+ * Adds a pair of arguments, e.g. option + value.
+ *
+ * @returns IPRT status code.
+ */
+int NetworkServiceRunner::addArgPair(const char *pszOption, const char *pszValue)
+{
+    int rc = addArgument(pszOption);
+    if (RT_SUCCESS(rc))
+        rc = addArgument(pszValue);
+    return rc;
+}
+
+
+void NetworkServiceRunner::resetArguments()
+{
+    m->resetArguments();
 }
 
@@ -94,9 +175,9 @@
 void NetworkServiceRunner::detachFromServer()
 {
-    m->mProcess = NIL_RTPROCESS;
-}
-
-
-int NetworkServiceRunner::start(bool aKillProcOnStop)
+    m->Process = NIL_RTPROCESS;
+}
+
+
+int NetworkServiceRunner::start(bool aKillProcessOnStop)
 {
     if (isRunning())
@@ -104,40 +185,38 @@
 
     /*
-     * Construct the path to the executable.  ASSUME it is relative to the
-     * directory that holds VBoxSVC.
+     * Construct the path to the executable and put in into the argument vector.
+     * ASSUME it is relative to the directory that holds VBoxSVC.
      */
     char szExePath[RTPATH_MAX];
     AssertReturn(RTProcGetExecutablePath(szExePath, RTPATH_MAX), VERR_FILENAME_TOO_LONG);
     RTPathStripFilename(szExePath);
-    int vrc = RTPathAppend(szExePath, sizeof(szExePath), m->mProcName);
+    int vrc = RTPathAppend(szExePath, sizeof(szExePath), m->pszProcName);
     AssertLogRelRCReturn(vrc, vrc);
 
-    /*
-     * Allocate the argument array and construct the argument vector.
-     */
-    size_t const cArgs     = 1 + m->mOptions.size() * 2 + 1;
-    char const **papszArgs = (char const **)RTMemTmpAllocZ(sizeof(papszArgs[0]) * cArgs);
-    AssertReturn(papszArgs, VERR_NO_TMP_MEMORY);
-
-    size_t iArg = 0;
-    papszArgs[iArg++] = szExePath;
-    for (std::map<std::string, std::string>::const_iterator it = m->mOptions.begin(); it != m->mOptions.end(); ++it)
-    {
-        papszArgs[iArg++] = it->first.c_str();
-        papszArgs[iArg++] = it->second.c_str();
-    }
-    Assert(iArg + 1 == cArgs);
-    Assert(papszArgs[iArg] == NULL);
+    if (m->cArgs == 0 && m->cArgsAlloc == 0)
+    {
+        m->cArgsAlloc = 2;
+        m->papszArgs = (char **)RTMemAllocZ(sizeof(m->papszArgs[0]) * 2);
+        AssertReturn(m->papszArgs, VERR_NO_MEMORY);
+    }
+    else
+        Assert(m->cArgsAlloc >= 2);
+    RTStrFree(m->papszArgs[0]);
+    m->papszArgs[0] = RTStrDup(szExePath);
+    AssertReturn(m->papszArgs[0], VERR_NO_MEMORY);
+    if (m->cArgs == 0)
+        m->cArgs = 1;
 
     /*
      * Start the process:
      */
-    int rc = RTProcCreate(szExePath, papszArgs, RTENV_DEFAULT, 0, &m->mProcess);
-    if (RT_FAILURE(rc))
-        m->mProcess = NIL_RTPROCESS;
-
-    m->mKillProcOnStop = aKillProcOnStop;
-
-    RTMemTmpFree(papszArgs);
+    int rc = RTProcCreate(szExePath, m->papszArgs, RTENV_DEFAULT, 0, &m->Process);
+    if (RT_SUCCESS(rc))
+        LogRel(("NetworkServiceRunning: started '%s', pid %RTproc\n", m->pszProcName, m->Process));
+    else
+        m->Process = NIL_RTPROCESS;
+
+    m->fKillProcessOnStop = aKillProcessOnStop;
+
     return rc;
 }
@@ -155,5 +234,5 @@
     bool fDoKillProc = true;
 
-    if (!m->mKillProcOnStop)
+    if (!m->fKillProcessOnStop)
     {
         /*
@@ -162,39 +241,47 @@
          * doing the final hard kill.
          */
-        int rc = VINF_SUCCESS;
         for (unsigned int i = 0; i < 100; i++)
         {
-            rc = RTProcWait(m->mProcess, RTPROCWAIT_FLAGS_NOBLOCK, NULL);
-            if (RT_SUCCESS(rc))
+            if (!isRunning())
+            {
+                fDoKillProc = false;
                 break;
+            }
             RTThreadSleep(10);
         }
-        if (rc != VERR_PROCESS_RUNNING)
-            fDoKillProc = false;
     }
 
     if (fDoKillProc)
     {
-        RTProcTerminate(m->mProcess);
-        int rc = RTProcWait(m->mProcess, RTPROCWAIT_FLAGS_BLOCK, NULL);
+        LogRel(("NetworkServiceRunning: killing %s, pid %RTproc...\n", m->pszProcName, m->Process));
+        RTProcTerminate(m->Process);
+
+        int rc = RTProcWait(m->Process, RTPROCWAIT_FLAGS_BLOCK, NULL);
         NOREF(rc);
     }
 
-    m->mProcess = NIL_RTPROCESS;
+    m->Process = NIL_RTPROCESS;
     return VINF_SUCCESS;
 }
 
+
+/**
+ * Checks if the service process is still running.
+ *
+ * @returns true if running, false if not.
+ */
 bool NetworkServiceRunner::isRunning()
 {
-    if (m->mProcess == NIL_RTPROCESS)
-        return false;
-
-    RTPROCSTATUS status;
-    int rc = RTProcWait(m->mProcess, RTPROCWAIT_FLAGS_NOBLOCK, &status);
-
-    if (rc == VERR_PROCESS_RUNNING)
-        return true;
-
-    m->mProcess = NIL_RTPROCESS;
+    RTPROCESS Process = m->Process;
+    if (Process != NIL_RTPROCESS)
+    {
+        RTPROCSTATUS ExitStatus;
+        int rc = RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, &ExitStatus);
+        if (rc == VERR_PROCESS_RUNNING)
+            return true;
+        LogRel(("NetworkServiceRunning: %s (pid %RTproc) stopped: iStatus=%u enmReason=%d\n",
+                m->pszProcName, m->Process, ExitStatus.iStatus, ExitStatus.enmReason));
+        m->Process = NIL_RTPROCESS;
+    }
     return false;
 }
