---
title: llarp/win32/exec.hpp

---

# llarp/win32/exec.hpp



## Namespaces

| Name           |
| -------------- |
| **[llarp](Namespaces/namespacellarp.md)** <br>[crypto.hpp] |
| **[llarp::win32](Namespaces/namespacellarp_1_1win32.md)**  |

## Classes

|                | Name           |
| -------------- | -------------- |
| class | **[llarp::win32::OneShotExec](Classes/classllarp_1_1win32_1_1OneShotExec.md)** <br>RAII wrapper for calling a subprocess in win32 for parallel executuion in the same scope destructor blocks until timeout has been hit of the execution of the subprocses finished.  |
| class | **[llarp::win32::DeferExec](Classes/classllarp_1_1win32_1_1DeferExec.md)** <br>a wrapper for [OneShotExec](Classes/classllarp_1_1win32_1_1OneShotExec.md) that calls the thing we want on destruction  |




## Source code

```cpp
#pragma once

#include <windows.h>
#include <string>
#include <llarp/util/time.hpp>

namespace llarp::win32
{
  class OneShotExec
  {
    STARTUPINFO _si;
    PROCESS_INFORMATION _pi;
    const DWORD _timeout;

    OneShotExec(std::string cmd, std::chrono::milliseconds timeout);

   public:
    explicit OneShotExec(std::string exe, std::string args, std::chrono::milliseconds timeout = 5s);

    ~OneShotExec();
  };

  class DeferExec
  {
    std::string _exe;
    std::string _args;
    std::chrono::milliseconds _timeout;

   public:
    explicit DeferExec(std::string exe, std::string args, std::chrono::milliseconds timeout = 5s)
        : _exe{std::move(exe)}, _args{std::move(args)}, _timeout{std::move(timeout)}
    {}

    ~DeferExec();
  };

  void
  Exec(std::string exe, std::string args);

}  // namespace llarp::win32
```


-------------------------------

Updated on 2022-11-17 at 22:27:42 +0000
