| 257 | return Fs::getParentPath(path); |
| 258 | } |
| 259 | void KProcess::clone(const KProcessPtr& from) { |
| 260 | this->parentId = from->id;; |
| 261 | this->groupId = from->groupId; |
| 262 | this->userId = from->userId; |
| 263 | this->effectiveUserId = from->effectiveUserId; |
| 264 | this->effectiveGroupId = from->effectiveGroupId; |
| 265 | this->currentDirectory = from->currentDirectory; |
| 266 | this->brkEnd = from->brkEnd; |
| 267 | for (auto& n : from->fds) { |
| 268 | KFileDescriptorPtr fromFd = n.value; |
| 269 | KFileDescriptorPtr fd = this->allocFileDescriptor(fromFd->kobject, fromFd->accessFlags, fromFd->descriptorFlags, n.key, 0); |
| 270 | this->fds.set(n.key, fd); |
| 271 | KObject* kobject = fd->kobject.get(); |
| 272 | Fs::addDynamicLinkFile(fdNode->path + "/" + BString::valueOf(n.key), k_mdev(0, 0), fdNode, false, [kobject] { |
| 273 | return kobject->selfFd(); |
| 274 | }); |
| 275 | } |
| 276 | // :TODO: not thread safe if from has multiple threads |
| 277 | this->mappedFiles = from->mappedFiles; |
| 278 | std::copy(from->sigActions, from->sigActions+MAX_SIG_ACTIONS, this->sigActions); |
| 279 | this->path = from->path; |
| 280 | this->commandLine = from->commandLine; |
| 281 | this->exe = from->exe; |
| 282 | this->name = from->name; |
| 283 | this->setupCommandlineNode(); |
| 284 | this->umaskValue = from->umaskValue; |
| 285 | |
| 286 | this->privateShm = from->privateShm; |
| 287 | |
| 288 | for (auto& n : from->attachedShm) { |
| 289 | std::shared_ptr<AttachedSHM> attached = std::make_shared<AttachedSHM>(n.value->shm, n.key, this->id); |
| 290 | this->attachedShm.set(n.key, attached); |
| 291 | } |
| 292 | |
| 293 | for (U32 i=0;i<LDT_ENTRIES;i++) { |
| 294 | this->ldt[i] = from->ldt[i]; |
| 295 | } |
| 296 | |
| 297 | this->loaderBaseAddress = from->loaderBaseAddress; |
| 298 | this->phdr = from->phdr; |
| 299 | this->phnum = from->phnum; |
| 300 | this->entry = from->entry; |
| 301 | |
| 302 | for (U32 i=0;i<6;i++) { |
| 303 | this->hasSetSeg[i] = from->hasSetSeg[i]; |
| 304 | } |
| 305 | this->hasSetStackMask = from->hasSetStackMask; |
| 306 | this->systemProcess = from->systemProcess; |
| 307 | } |
| 308 | |
| 309 | static void writeStackString(KThread* thread, CPU * cpu, const char* s) { |
| 310 | int count = (int)((strlen(s)+4)/4); |
nothing calls this directly
no test coverage detected