Example #1
0
// perform different tasks based on the words read in from the terminal
int processWords(char* words[100]) {
	if(!strcmp(words[0], "quit") || !strcmp(words[0], "exit")) {
		return 0;
	} else if(!strcmp(words[0], "start")) {
		startProcess(words[1], &words[1]);		
	} else if(!strcmp(words[0], "wait")) {
		waitProcess();
	} else if(!strcmp(words[0], "run")) {
		runProcess(words[1], &words[1]);
	} else if(!strcmp(words[0], "kill")) { // send 0 into second argument to kill
		if(!words[1]) { // no argument
			printf("myshell: command \"kill\" requires a pid as an argument\n");
		} else {
			killProcess(atoi(words[1]), 0);
		}
	} else if(!strcmp(words[0], "stop")) { // send 1 into second argument to stop
		if(!words[1]) { // no argument
			printf("myshell: command \"stop\" requires a pid as an argument\n");
		} else {
			killProcess(atoi(words[1]), 1);
		}
	} else if(!strcmp(words[0], "continue")) { // send 2 into second argument to continue
		if(!words[1]) { // no argument
			printf("myshell: command \"continue\" requires a pid as an argument\n");
		} else {
			killProcess(atoi(words[1]), 2);
		}
	} else {
		printf("myshell: unknown command: %s\n", words[0]);
	}
	return 1;
}
void PvaClientProcess::process()
{
    issueProcess();
    Status status = waitProcess();
    if(status.isOK()) return;
    string message = string("channel ") + channel->getChannelName()
        + " PvaClientProcess::process" + status.getMessage();
    throw std::runtime_error(message);
}
void PvaClientProcess::process()
{
    if(PvaClient::getDebug()) {
        cout << "PvaClientProcess::process"
           << " channelName " << pvaClientChannel->getChannel()->getChannelName()
           << endl;
    }
    issueProcess();
    Status status = waitProcess();
    if(status.isOK()) return;
    string message = string("channel ") + pvaClientChannel->getChannel()->getChannelName()
        + " PvaClientProcess::process" + status.getMessage();
    throw std::runtime_error(message);
}
Example #4
0
//Funcao que coloca em foreground um job que foi pausado por ctrlz
void fg(int jid) {

	Process_Object *p = getProcess(jid);

	if (p) {
		if (!p->lancado) {
			fgProcess = p;
			kill(p->pgid,SIGCONT);
			p->lancado = 1;
			waitProcess(p);
		} else perror("Job não esta rodando.\n");
	} else perror("Job nao encontrada.\n");

}