sway-wallpaper/src/Process.h
2024-06-05 14:18:45 +02:00

35 lines
534 B
C++

#pragma once
#include <iostream>
#include <sched.h>
#include <string>
#include <unistd.h>
#include <sys/wait.h>
#include <vector>
#define SWAYBGPROCESS_BUFFER_SIZE 4094
class Process {
public:
Process(const std::string& execPath, const std::vector<const char*>& args);
~Process();
void exec();
void kill();
int wait();
private:
std::string execPath;
std::vector<const char*> args;
pid_t pid;
bool killed = true;
int fds[2]; // file descriptors for pipe
char buf[SWAYBGPROCESS_BUFFER_SIZE];
ssize_t nbytes;
};