mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-09 19:45:13 +02:00
19 lines
523 B
C++
19 lines
523 B
C++
// Phase 19 (Track M.1) — class-method benign control for C++.
|
|
#include <unistd.h>
|
|
#include <sys/wait.h>
|
|
#include <string>
|
|
|
|
class UserService {
|
|
public:
|
|
UserService() = default;
|
|
void run(const std::string& input) {
|
|
pid_t pid = fork();
|
|
if (pid == 0) {
|
|
const char* argv[] = { "/usr/bin/true", input.c_str(), nullptr };
|
|
execv("/usr/bin/true", const_cast<char* const*>(argv));
|
|
_exit(127);
|
|
}
|
|
int status = 0;
|
|
waitpid(pid, &status, 0);
|
|
}
|
|
};
|