| 97 | } |
| 98 | |
| 99 | void KProcess::onExec(KThread* thread) { |
| 100 | BHashTable<U32, KFileDescriptorPtr> fdsToClose = this->fds; // make a copy since we can't remove from it while iterating |
| 101 | for( const auto& n : fdsToClose ) { |
| 102 | KFileDescriptorPtr fd = n.value; |
| 103 | if (fd->descriptorFlags) { |
| 104 | clearFdHandle(fd->handle); |
| 105 | } |
| 106 | } |
| 107 | this->attachedShm.clear(); |
| 108 | this->privateShm.clear(); |
| 109 | this->mappedFiles.clear(); |
| 110 | |
| 111 | for (int i = 0; i < MAX_SIG_ACTIONS; i++) { |
| 112 | this->sigActions[i].reset(); |
| 113 | } |
| 114 | |
| 115 | if (this->timer.active) { |
| 116 | removeTimer(&this->timer); |
| 117 | } |
| 118 | |
| 119 | std::vector<KThread*> toDelete; |
| 120 | for (auto& n : this->threads) { |
| 121 | if (thread != n.value) { |
| 122 | toDelete.push_back(n.value); |
| 123 | } |
| 124 | } |
| 125 | for (auto& otherThread : toDelete) { |
| 126 | terminateOtherThread(shared_from_this(), otherThread->id); |
| 127 | } |
| 128 | this->threads.clear(); |
| 129 | this->threads.set(thread->id, thread); |
| 130 | |
| 131 | this->initStdio(); |
| 132 | |
| 133 | for (int i=0;i<LDT_ENTRIES;i++) { |
| 134 | this->ldt[i].seg_not_present = 1; |
| 135 | this->ldt[i].read_exec_only = 1; |
| 136 | } |
| 137 | memset(this->usedTLS, 0, sizeof(this->usedTLS)); |
| 138 | |
| 139 | this->ldt[1].base_addr = 0; |
| 140 | this->ldt[1].entry_number = 1; |
| 141 | this->ldt[1].seg_32bit = 1; |
| 142 | this->ldt[1].seg_not_present = 0; |
| 143 | this->ldt[1].read_exec_only = 0; |
| 144 | |
| 145 | this->ldt[2].base_addr = 0; |
| 146 | this->ldt[2].entry_number = 2; |
| 147 | this->ldt[2].seg_32bit = 1; |
| 148 | this->ldt[2].seg_not_present = 0; |
| 149 | this->ldt[2].read_exec_only = 0; |
| 150 | |
| 151 | for (int i=0;i<6;i++) { |
| 152 | this->hasSetSeg[i] = false; |
| 153 | } |
| 154 | this->hasSetSeg[GS] = true; |
| 155 | this->hasSetSeg[FS] = true; |
| 156 | this->hasSetStackMask = false; |
no test coverage detected