如果用户在shell命令行中输入"shutdown"或"restart",我试图让我的shell终止.一切都很好.我用C(strtok,cstring)和C++编写代码.当我使用valgrind时,它表示仍然可以访问1个块.我知道这不是泄漏,但我很想知道是什么导致它以及如何解决它.花了2天试图找到它不能.请查看我的代码和valgrind报告.
码
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
using namespace std;
const int MAX_COMMAND_LINE_ARGUMENTS = 8;
const int SLEEP_DELAY = 100000;
int GetCommand (string tokens []);
int TokenizeCommandLine (string tokens [], string commandLine);
bool CheckForCommand ();
void ProcessCommand (string tokens [], int tokenCount);
void ShutdownAndRestart (string tokens [], int tokenCount);
static volatile sig_atomic_t cullProcess = 0;
int main()
{
string tokens [MAX_COMMAND_LINE_ARGUMENTS];
int tokenCount;
do
{
tokenCount = GetCommand (tokens); …Run Code Online (Sandbox Code Playgroud)