void start_stdinput(boost::asio::io_service & io_service) { #if defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR) boost::shared_ptr<boost::asio::posix::stream_descriptor> stdin( new boost::asio::posix::stream_descriptor( io_service, 0 ) ); boost::shared_ptr<boost::asio::streambuf> inputbuffer( new boost::asio::streambuf ); boost::asio::async_read_until( *stdin, *inputbuffer, '\n', boost::bind(inputread , _1, _2, stdin, inputbuffer) ); #elif defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE) boost::shared_ptr<boost::asio::windows::object_handle> consolehandle(new boost::asio::windows::object_handle(io_service, GetStdHandle(STD_INPUT_HANDLE))); async_console_read_line( *consolehandle, boost::bind(&console_read, _1, consolehandle) ); #else boost::thread( boost::bind(input_thread, boost::ref(io_service)) ); #endif }
void NXClientLib::write(QString data) { nxsshProcess.write(data.toAscii()); if (password) { data = "********"; password = false; } emit stdin(data); cout << data.toStdString(); }
void start_stdinput(boost::asio::io_service & io_service) { #ifdef BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR boost::shared_ptr<boost::asio::posix::stream_descriptor> stdin( new boost::asio::posix::stream_descriptor( io_service, 0 ) ); boost::shared_ptr<boost::asio::streambuf> inputbuffer( new boost::asio::streambuf ); boost::asio::async_read_until( *stdin, *inputbuffer, '\n', boost::bind(inputread , _1, _2, stdin, inputbuffer) ); #else boost::thread( boost::bind(input_thread, boost::ref(io_service)) ); #endif }
int32_t execute(const uint8_t* command) { pcb_t* previous_pcb = curr_process; char* cmd = (char*)command; uint8_t* fname = (uint8_t*)parse(cmd); get_arg((char *)command, (int)strlen(cmd)); /* Looking for processes */ uint8_t process_mask = MASK; // Calculating the process mask, which keeps track of open processes. Here we search for a 0 in the mask // and set it to 1, giving the index in the bitmap to process_id int i = 0; for(i = 0; i < 7; i++) { if((process_mask & open_processes) == 0) { open_processes |= process_mask; process_id = i; break; } else process_mask >>= 1; } // if(num_processes + 1 > 2) // { // cout("PROCESS LIMIT EXCEEDED. NOT ALLOWED TO EXECUTE\n"); // //num_processes--; // sti(); // asm volatile("jmp ret_halt"); // } // Check if(i == 7) { printf("Too many processes!\n"); return 1; } /* Executable check */ uint8_t elf_check[4]; dentry_t dentry_temp; if(-1 == read_dentry_by_name(fname, &dentry_temp)) { return -1; } if(-1 == read_data(dentry_temp.inode_num, 0, elf_check, 4)) { return -1; } if(!(elf_check[0] == 0x7f && elf_check[1] == 0x45 && elf_check[2] == 0x4c && elf_check[3] == 0x46)) { return -1; } /* Find the address of the file's first instruction */ uint8_t buf_temp[4]; if(-1 == read_data(dentry_temp.inode_num, 24, buf_temp, 4)) { return -1; } int k = 0; uint32_t entry_addr = 0; for(k = 0; k < 4; k++) entry_addr |= (buf_temp[k] << 8*k); /* Set up paging */ PDE_t* PD_ptr = task_mem_init(process_id); if(PD_ptr == NULL) { printf("Too many processes!\n"); return 1; } // Load program image into memory if(-1 == program_load(fname, PGRM_IMG)) { return -1; } k_bp = _8MB - (_8KB)*(process_id) - 4; curr_process = (pcb_t *) (k_bp & 0xFFFFE000); // k_bp = _8MB - (_8KB)*(process_id); // curr_process = (pcb_t *) ((k_bp - 1) & 0xFFFFE000); curr_process->process_id = process_id; curr_process->PD_ptr = PD_ptr; curr_process->k_bp = k_bp; curr_process->k_sp = k_bp; // If initial shell, case should be handeled by making parent process the same shell if(initial_shell) { curr_process->parent_process = curr_process; curr_process->child_flag = 0; curr_process->parent_process->child = -1; initial_shell = 0; } else { curr_process->parent_process = previous_pcb; curr_process->parent_process->child_flag = 1; curr_process->parent_process->child = process_id; } // Initialize file descriptors for(i = 0; i < 8; i++) { curr_process->file_fds[i].file_op = NULL; curr_process->file_fds[i].inode_ptr = NULL; curr_process->file_fds[i].file_pos = 0; curr_process->file_fds[i].flags = 0; } task_queue[next_available] = process_id; next_available = (next_available + 1) % 7; stdin(0); //kernel should automatically open stdin and stdout stdout(1); //which correspond to fd 0 and 1 respectively task_queue[next_available] = process_id; next_available = (next_available + 1) % 7; // Setting TSS tss.esp0 = curr_process->k_sp; // This is good code tss.ss0 = KERNEL_DS; if(previous_pcb != NULL) { asm volatile("movl %%esp, %0":"=g"(previous_pcb->k_sp)); asm volatile("movl %%ebp, %0":"=g"(previous_pcb->k_bp)); } // Jump to program and being executions jump_to_userspace(entry_addr); // Halt jumps here for finishing execute asm volatile("ret_halt:\n\t"); return retval; }
int foo () { return memmove() + malloc() + system() + stdin() + memccpy() + free() + strdup() + atoi(); }