2024-12-21 16:47:46 +01:00
|
|
|
#include <csignal>
|
|
|
|
#include <cerrno>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <unistd.h>
|
2024-10-14 23:26:41 +02:00
|
|
|
#include <hyprutils/os/Process.hpp>
|
|
|
|
#include "shared.hpp"
|
|
|
|
|
|
|
|
using namespace Hyprutils::OS;
|
|
|
|
|
|
|
|
int main(int argc, char** argv, char** envp) {
|
|
|
|
int ret = 0;
|
|
|
|
|
2024-11-15 21:28:59 +01:00
|
|
|
CProcess process("sh", {"-c", "echo \"Hello $WORLD!\""});
|
|
|
|
process.addEnv("WORLD", "World");
|
2024-10-14 23:26:41 +02:00
|
|
|
|
|
|
|
EXPECT(process.runAsync(), true);
|
|
|
|
EXPECT(process.runSync(), true);
|
|
|
|
|
|
|
|
EXPECT(process.stdOut(), std::string{"Hello World!\n"});
|
|
|
|
EXPECT(process.stdErr(), std::string{""});
|
|
|
|
|
2024-12-21 16:47:46 +01:00
|
|
|
CProcess process2("sh", {"-c", "while true; do sleep 1; done;"});
|
|
|
|
|
|
|
|
EXPECT(process2.runAsync(), true);
|
|
|
|
EXPECT(getpgid(process2.pid()) >= 0, true);
|
|
|
|
|
|
|
|
kill(process2.pid(), SIGKILL);
|
|
|
|
|
2024-10-14 23:26:41 +02:00
|
|
|
return ret;
|
|
|
|
}
|