fix: add start pending mode to mitigate Terminal output redirection issue
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user