fix: add start pending mode to mitigate Terminal output redirection issue

This commit is contained in:
2026-05-07 07:32:44 +02:00
parent 2523340d08
commit ecf6edb826
4 changed files with 59 additions and 11 deletions
+7 -2
View File
@@ -46,10 +46,11 @@ namespace Montauk {
auto* parent = Sched::GetCurrentProcessPtr();
int parentSlot = Ipc::CurrentSlot();
int childPid = Sched::Spawn(resolved, args);
bool inheritRedirection = parent && parent->redirected;
int childPid = Sched::Spawn(resolved, args, !inheritRedirection);
if (childPid < 0) return childPid;
if (parent && parent->redirected) {
if (inheritRedirection) {
auto* child = Sched::GetProcessByPid(childPid);
int childSlot = Ipc::SlotForPid(childPid);
if (child == nullptr || childSlot < 0 || parentSlot < 0) {
@@ -71,6 +72,10 @@ namespace Montauk {
child->parentPid = parent->pid;
child->termCols = parent->termCols;
child->termRows = parent->termRows;
if (Sched::StartProcess(childPid) < 0) {
Sched::KillProcess(childPid);
return -1;
}
}
return childPid;