Пример #1
0
void GdbPlainEngine::setupInferior()
{
    QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
    setEnvironmentVariables();
    if (!runParameters().inferior.commandLineArguments.isEmpty()) {
        QString args = runParameters().inferior.commandLineArguments;
        runCommand({"-exec-arguments " + toLocalEncoding(args), NoFlags});
    }
    runCommand({"-file-exec-and-symbols \"" + execFilePath() + '"', NoFlags,
        CB(handleFileExecAndSymbols)});
}
Пример #2
0
ProcessHandleImpl* ProcessImpl::launchByForkExecImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
{
	int pid = fork();
	if (pid < 0)
	{
		throw SystemException("Cannot fork process for", command);		
	}
	else if (pid == 0)
	{
		if (!initialDirectory.empty())
		{
			if (chdir(initialDirectory.c_str()) != 0)
			{
				_exit(72);
			}
		}

		setEnvironmentVariables(env);

		// setup redirection
		if (inPipe)
		{
			dup2(inPipe->readHandle(), STDIN_FILENO);
			inPipe->close(Pipe::CLOSE_BOTH);
		}
		// outPipe and errPipe may be the same, so we dup first and close later
		if (outPipe) dup2(outPipe->writeHandle(), STDOUT_FILENO);
		if (errPipe) dup2(errPipe->writeHandle(), STDERR_FILENO);
		if (outPipe) outPipe->close(Pipe::CLOSE_BOTH);
		if (errPipe) errPipe->close(Pipe::CLOSE_BOTH);
		// close all open file descriptors other than stdin, stdout, stderr
		for (int i = 3; i < getdtablesize(); ++i)
			close(i);

		char** argv = new char*[args.size() + 2];
		int i = 0;
		argv[i++] = const_cast<char*>(command.c_str());
		for (ArgsImpl::const_iterator it = args.begin(); it != args.end(); ++it) 
			argv[i++] = const_cast<char*>(it->c_str());
		argv[i] = NULL;
		execvp(command.c_str(), argv);
		_exit(72);
	}

	if (inPipe)  inPipe->close(Pipe::CLOSE_READ);
	if (outPipe) outPipe->close(Pipe::CLOSE_WRITE);
	if (errPipe) errPipe->close(Pipe::CLOSE_WRITE);
	return new ProcessHandleImpl(pid);
}
Пример #3
0
ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
{
	char** argv = new char*[args.size() + 2];
	int i = 0;
	argv[i++] = const_cast<char*>(command.c_str());
	for (ArgsImpl::const_iterator it = args.begin(); it != args.end(); ++it) 
		argv[i++] = const_cast<char*>(it->c_str());
	argv[i] = NULL;
	try
	{
		int pid = vfork();
		if (pid < 0)
		{
			throw SystemException("Cannot fork process for", command);		
		}
		else if (pid == 0)
		{
			if (!initialDirectory.empty())
			{
				if (chdir(initialDirectory.c_str()) != 0)
				{
					std::stringstream str;
					str << "Cannot set initial directory to '" << initialDirectory << "' when forking process for";
					throw SystemException(str.str(), command);		
				}
			}
			setEnvironmentVariables(environment_variables);

			if (execvp(command.c_str(), argv) == -1)
				throw SystemException("Cannot execute command", command);
		}
		else 
		{
			delete [] argv;
			return new ProcessHandleImpl(pid);
		}
	}
	catch (...)
	{
		delete [] argv;
		throw;
	}
}
Пример #4
0
ProjectBuild::ProjectBuild(QDomDocument *proj, Ide *parent,
                           ProjectSettings *settings, CommandLine *cmd)
    : QWidget(parent), cmd(cmd)
{

    this->parent = parent;
    proc = NULL;

    QDomNodeList lst = proj->elementsByTagName("task");

    path = parent->whcFile;

    path.remove(path.split("/").last());

    for(int i = 0; i<lst.count(); i++)
     {
        QString tmp = lst.at(i).attributes().namedItem("name").nodeValue();

        paths += path + "src/" + tmp + "/build";

     }
    setEnvironmentVariables(settings);
}