Store standard file descriptors

This commit is contained in:
Baptiste Wicht 2016-09-22 20:18:18 +02:00
parent f266b95c37
commit c53f66af49

View File

@ -271,6 +271,13 @@ void create_init_task(){
scheduler::queue_system_process(init_process.pid);
init_pid = init_process.pid;
//TODO Get the tty from the current terminal
// Create the 0,1,2 file descriptors
pcb[init_pid].handles.emplace_back("/dev/tty0");
pcb[init_pid].handles.emplace_back("/dev/tty0");
pcb[init_pid].handles.emplace_back("/dev/tty0");
}
void create_gc_task(){
@ -658,6 +665,11 @@ std::expected<scheduler::pid_t> scheduler::exec(const std::string& file, const s
pcb[process.pid].working_directory = pcb[current_pid].working_directory;
// Inherit standard file descriptors from the parent
pcb[process.pid].handles.emplace_back(pcb[current_pid].handles[0]);
pcb[process.pid].handles.emplace_back(pcb[current_pid].handles[1]);
pcb[process.pid].handles.emplace_back(pcb[current_pid].handles[2]);
logging::logf(logging::log_level::DEBUG, "scheduler: Exec process pid=%u, ppid=%u\n", process.pid, process.ppid);
queue_process(process.pid);