| 403 | } |
| 404 | |
| 405 | static void setupThreadStack(KThread* thread, CPU* cpu, BString programName, const std::vector<BString>& args, const std::vector<BString>& env) { |
| 406 | U32 a[MAX_ARG_COUNT] = {}; |
| 407 | U32 e[MAX_ARG_COUNT] = {}; |
| 408 | |
| 409 | cpu->push32(0); |
| 410 | cpu->push32(0); |
| 411 | cpu->push32(0); |
| 412 | writeStackString(thread, cpu, programName.c_str()); |
| 413 | if (args.size()>MAX_ARG_COUNT) |
| 414 | kpanic_fmt("Too many args: %d is max", MAX_ARG_COUNT); |
| 415 | if (env.size()>MAX_ARG_COUNT) |
| 416 | kpanic_fmt("Too many env: %d is max", MAX_ARG_COUNT); |
| 417 | //klog("env"); |
| 418 | for (size_t i=0;i<env.size();i++) { |
| 419 | writeStackString(thread, cpu, env[i].c_str()); |
| 420 | if (strncmp(env[i].c_str(), "PATH=", 5)==0) { |
| 421 | env[i].substr(5).split(':', cpu->thread->process->path); |
| 422 | } |
| 423 | //klog(" %s", env[i]); |
| 424 | e[i]=ESP; |
| 425 | } |
| 426 | for (S32 i=(S32)args.size()-1;i>=0;i--) { |
| 427 | writeStackString(thread, cpu, args[i].c_str()); |
| 428 | a[i]=ESP; |
| 429 | } |
| 430 | |
| 431 | pushThreadStack(thread, cpu, (U32)args.size(), a, (U32)env.size(), e); |
| 432 | } |
| 433 | |
| 434 | U32 KProcess::getNextFileDescriptorHandle(int after) { |
| 435 | BOXEDWINE_CRITICAL_SECTION_WITH_MUTEX(fdsMutex); |
no test coverage detected