Ejemplo n.º 1
0
int _hang (int argc, char ** argv)
{
	int pid = pcreate("smallhang", 0, NULL);
	prun(pid);
	while(1);
	return 0;
}
Ejemplo n.º 2
0
void packet_dump( 
    const std::string& lib = "/phenix/u/beaumim/VernierAnalysis/prdf_analysis/prdf_tools/full_prdf_scalers/scaler_dump/librun_scalers.so",
    const std::string& PRDF_name = "/gpfs02/phenix/spin3/beaumim/Run12VernierPRDF/files/VSCANDATA_P00-0000364636-0005.PRDFF",
    const std::string& out_file_name = "testout.txt"
    ) {
  gSystem->Load(lib.c_str());
  set_output_file(out_file_name);
  pfileopen(PRDF_name.c_str());
  prun(0);
  finish();
  std::cout << "Job done!" << std::endl;
}
Ejemplo n.º 3
0
/** Starts a shell, it's a user process, but yes, resides in the kernel's code */
int tty_main (int argc, char ** argv)
{	
	clear_screen();
	
	char cadena[50];
	
	int status     = 0; // 0: logged out; 1: logged in
	int val        = 0;
	int tty_number = 0;
	val = 0;
	tty_number = atoi(argv[1]) + 1;
	char * input;
	char * username;
	char * password;

	
	printf("Monix v1 - TTY %d\n", tty_number);
	printf("Cristian Pereyra  -  Legajo 51190\n");
	printf("Sistemas Operativos - 2011 - ITBA\n");
	printf("Dennis Ritchie RIP\n");

	int child;
	while(1) {
		switch (status){
			case 1:
				printf("user@tty%d:", tty_number);
				input = (char *) getConsoleString(1);
				process_input(input, tty_number);
				if(getuid(NULL) == -1)
				{
					status = 0;
				}
				break;
			case 0:
				child = pcreate("su", 1, NULL);
				prun(child);
				waitpid(child);
				if(getuid(NULL) != -1)	{
					status = 1;
				}
				break;
		}
	}
	return 0;
}
Ejemplo n.º 4
0
Archivo: tvm.c Proyecto: tgrehawi/tvm
int main(int argc, char *argv[]) {
	if (argc < 2) {
		usage(argv[0]);
	}
	else {
		char *fname = argv[1];
		FILE *file = fopen(fname, "r");
		if (file == NULL) {
			printf ("invalid file: %s\n", fname);
			return -1;
		}
		program p;
		ploadret ret = pload(&p, file);
		if (ret.type == SUCCESS) {
			printf("%d instructions loaded successfully\n", p.length);
		}
		else {
			printf("error loading source: ");
			switch (ret.type) {
				case SUCCESS:
					printf("SUCCESS");
					break;
				case INVALID_INSTRUCTION:
					printf("INVALID_INSTRUCTION");
					break;
				case INVALID_INTEGER:
					printf("INVALID_INTEGER");
					break;
				case INVALID_ESCAPE:
					printf("INVALID_ESCAPE");
					break;
			}
			printf(" in %s:%d:%d: '%c'(%d)\n", fname, ret.line, ret.column, ret.symbol, ret.symbol);
			return ret.type;
		}
		fclose(file);
		printf("\nprogram output:\n");
		progstate state = progstatenew();
		int r = prun(&state, p);
		putchar('\n');
		pfree(p);
		return r;
	}
}
Ejemplo n.º 5
0
int pashello_main(int argc, FAR char *argv[])
#endif
{
  int exitcode = EXIT_SUCCESS;
  int ret;

  /* Register the /dev/hello driver */

  hello_register();

  /* Execute the POFF file */

  ret = prun("/dev/hello", CONFIG_EXAMPLES_PASHELLO_VARSTACKSIZE,
             CONFIG_EXAMPLES_PASHELLO_STRSTACKSIZE);
  if (ret < 0)
    {
      fprintf(stderr, "pashello_main: ERROR: Execution failed\n");
      exitcode = EXIT_FAILURE;
    }

  printf("pashello_main: Interpreter terminated");
  return exitcode;
}
Ejemplo n.º 6
0
Archivo: main.c Proyecto: bgoglin/ompi
int main(int argc, char *argv[])
{
    return prun(argc, argv);
}
Ejemplo n.º 7
0
/** Reads the command received and excecutes the corrisponding process sending it it's arguments and 
also responds to special characters.*/
int process_input(const char * input, int tty_number) { 

	int  piped = 0;
	char file_call_buffer[1024];
	char stdout_call_buffer[128];
	char stdin_call_buffer[128];
	
	int stdout_file = 0;
	int stdin_file = 0;
	int read_ptr = 0;
	int stdin = 0;
	int stdout = 0;
	do {
		int i = 0;
		int write_i = 0;
		for(; i < 128; ++i) {
			stdout_call_buffer[i] = 0;
			stdin_call_buffer[i]  = 0;
		}

		for(i = 0; i < 1024; ++i)	{
			file_call_buffer[i] = 0;
		}
		i = read_ptr;
		
		char * file_call;

		
		int valid_input = 0;
		char * current_buffer = file_call_buffer;
		for(; input[i] && input[i] != '|'; ++i) {
			if(strlen(current_buffer) > 0 ) {
				if(input[i] == '>') {
					current_buffer = stdout_call_buffer;
					valid_input = 0;
					write_i = 0;
					stdout_file = 1;

					continue;
				} else if (input[i] == '<') { 
					current_buffer = stdin_call_buffer;
					valid_input = 0;
					write_i = 0;
					stdin_file = 1;
					continue;
				}
			} else {
				if (input[i] == '>' || input[i] == '<') {
					return 0;
				}
			}
			valid_input = input[i] != ' ';
			if(!(write_i == 0 && !valid_input)) {
				current_buffer[write_i++] = input[i];
			}
		}
		if(i == 0 && input[i] == '|') {
			return 0;
		}
		piped = (input[i] == '|') && !stdin_file && !stdout_file; 
		i++;
		
		if(piped)
		{
			read_ptr = i;
		}
		
		int n = 0;
		char** strs = split_string(file_call_buffer, ' ', &n);
		
		
		int pid = pcreate(strs[0], n, strs);
		
		if(pid != -1)
		{
			if(stdout_file) {
				int _stdout = open(stdout_call_buffer, O_WR | O_NEW);
				if(_stdout >= 0)
				{
					pdup2(pid, _stdout, STDOUT);
 				} else {
					printf("TTY: file %s could not be opened for output, invalid perms?\n", stdout_call_buffer);
				}
			}
			
			if(stdin_file) {
				int _stdin = open(stdin_call_buffer, O_RD);
				if(_stdin >= 0)
				{
					pdup2(pid, _stdin, STDIN);
				} else {
					printf("TTY: file %s could not be opened for input, invalid perms?\n", stdin_call_buffer);
				}

			}
			
			// For pipe
			if(stdin)	{
				pdup2(pid, stdin, STDIN);
			}
			char cad[20];
			if(piped)
			{
				cad[0] = '.';
				itoa(pid, cad + 1);
				stdout = mkfifo(cad, 0600);
				pdup2(pid,stdout,STDOUT);
				stdin = stdout;
				stdout = 0;
			}
			
			prun(pid);
			if(!string_ends_with(file_call_buffer, '&') && !piped) {
				waitpid(pid);
				rm(cad);
			}
		}
	} while(piped);
	return 1;
}
Ejemplo n.º 8
0
bool dllForExport::run(QString projectfile, QString target)
{
    if(prun!=0)return prun(projectfile, target);
    else gcerror(QString("The exporter %1's RUN function is not implemented").arg(exportername));
}