fix(mtproto): synchronize child-process lifecycle (#6141)

* fix(mtproto): synchronize child-process state

Use lifecycle snapshots around the mtg command, completion signal, and exit error so Wait cannot race status and shutdown reads.

* test(mtproto): cover concurrent process exit

* test(mtproto): cover lifecycle field synchronization

---------

Co-authored-by: PathGao <gaoyanbo@gaoyanbodeMacBook-Air.local>
This commit is contained in:
PathGao
2026-07-30 02:56:26 +08:00
committed by GitHub
parent 863473783d
commit 03cc80bb9e
3 changed files with 166 additions and 29 deletions
+10
View File
@@ -21,6 +21,16 @@ func TestMain(m *testing.M) {
fmt.Fprintf(f, "%d\n", os.Getpid())
f.Close()
}
if exitFile := os.Getenv("MTG_FAKE_EXIT_FILE"); exitFile != "" {
for {
if _, err := os.Stat(exitFile); err == nil {
os.Exit(1)
} else if !os.IsNotExist(err) {
os.Exit(2)
}
time.Sleep(time.Millisecond)
}
}
select {}
}
os.Exit(m.Run())