Here you go. Since you are a programming engineer, you will immediately understand what I mean when I say….
#include <iostream>
#include <cstdlib> // For system() function
#include <string>
void goSilentAndShutdown(const std::string &processName) {
// Command to silence the program (redirect output to null)
std::string silenceCommand = "pkill -STOP " + processName; // For Linux/Unix
if (system(silenceCommand.c_str()) == 0) {
std::cout << "Program silenced successfully." << std::endl;
} else {
std::cerr << "Failed to silence the program." << std::endl;
}
// Command to terminate the program
std::string shutdownCommand = "pkill -KILL " + processName; // For Linux/Unix
if (system(shutdownCommand.c_str()) == 0) {
std::cout << "Program shutdown successfully." << std::endl;
} else {
std::cerr << "Failed to shut down the program." << std::endl;
}
}
int main() {
std::string targetProcess;
std::cout << "Enter the name of the process to silence and shut down: ";
std::cin >> targetProcess;
goSilentAndShutdown(targetProcess);
return 0;
}
In other words, stfu.