File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -27,18 +27,21 @@ func (tt *TermTest) waitIndefinitely() error {
2727
2828 tt .opts .Logger .Printf ("Waiting for PID %d to exit\n " , tt .Cmd ().Process .Pid )
2929 for {
30- // There is a race condition here; which is that the pty could still be processing the last of the output
31- // when the process exits. This sleep tries to work around this, but on slow hosts this may not be sufficient.
32- // This also gives some time in between process lookups
33- time .Sleep (100 * time .Millisecond )
34-
3530 // For some reason os.Process will always return a process even when the process has exited.
3631 // According to the docs this shouldn't happen, but here we are.
3732 // Using gopsutil seems to correctly identify the (not) running process.
3833 exists , err := gopsutil .PidExists (int32 (tt .Cmd ().Process .Pid ))
3934 if err != nil {
4035 return fmt .Errorf ("could not find process: %d: %w" , tt .Cmd ().Process .Pid , err )
4136 }
37+
38+ // There is a race condition here; which is that the pty could still be processing the last of the output
39+ // when the process exits. This sleep tries to work around this, but on slow hosts this may not be sufficient.
40+ // We want this after the process state is asserted, but before we break out, to ensure we give at least the
41+ // specified time AFTER the process has exited.
42+ // This also povides time between process lookups.
43+ time .Sleep (100 * time .Millisecond )
44+
4245 if ! exists {
4346 break
4447 }
You can’t perform that action at this time.
0 commit comments