Пример #1
0
int runSeq(char ** command, struct node *paths){
	//stat check here
	char* goodCommand = pathCheck(command[0], paths);
	if(goodCommand == NULL){
		printf("OH NO! COULDN'T EXECUTE THAT COMMAND: %s\n", command[0]);
		return 1;
	}else{
		command[0] = goodCommand;
	}
	pid_t p = fork();
	if (p == 0) {
		/* in child */
		if (execv(command[0], command) < 0) {
			fprintf(stderr, "OH NO! COULDN'T EXECUTE THAT COMMAND: %s\n", strerror(errno));
			return -2;
		}
	} else if (p > 0) {
		/* in parent */
		int rstatus = 0;
		pid_t childp = wait(&rstatus);
		/* for this simple starter code, the only child process we should
	   "wait" for is the one we just spun off, so check that we got the
	   same process id */ 
		assert(p == childp);
		printf("CHILD PROCESS (%d) DID AN EXEC AND GOT PASSED TO IT'S PARENT. Return val %d\n", childp, rstatus);
	} else {
	 	/* fork had an error; bail out */
		fprintf(stderr, "OH NO! WE HAD A FAILURE WHEN FORKING TO A CHILD: %s\n", strerror(errno));
	}
	
	return 1;
}
Пример #2
0
void SettingsManager::setBackupPath(const QString &value)
{
    QString path = QDir::cleanPath(value);
    QDir dir(path);
    if(dir.exists() || pathCheck(path))
    {
        m_setting.setValue(c_setting_key_backupSavePath, path);
        emit signal_backupPathChanged(path);
    }
}
Пример #3
0
QString SettingsManager::getBackupPath()
{
    if(!m_setting.contains(c_setting_key_backupSavePath))
    {
        QString path = QDir::cleanPath(QCoreApplication::applicationDirPath() + c_setting_value_initBackupSavePath);
        m_setting.setValue(c_setting_key_backupSavePath, path);
    }
    QString path = m_setting.value(c_setting_key_backupSavePath).toString();;
    pathCheck(path);
    return path;
}