运行时: 当 stdin 生成器在读取器打开之前退出时, CloseIO 会阻塞

作者: frank-dong-ms创建于 2026年9月29日更新于 2026年9月29日

func makeFIFO(t *testing.T, name string) string { t.Helper() path := filepath.Join(t.TempDir(), name) require.NoError(t, syscall.Mkfifo(path, 0600)) return path }

func awaitIO(t *testing.T, done <-chan struct{}) { t.Helper() select { case <-done: case <-time.After(5 * time.Second): t.Fatal("IO worker did not complete") } }

func awaitIOError(t *testing.T, result <-chan error) error { t.Helper() select { case err := <-result: return err case <-time.After(5 * time.Second): t.Fatal("IO operation did not complete") return nil } }

type testStdin struct { bytes.Buffer }

func (*testStdin) Close() error { return nil }

func fifoTestProcess(t *testing.T, path string, guest io.WriteCloser, execID string) (*service, *taskAPI.CloseIORequest, *ttyIO, <-chan struct{}) { t.Helper() s, err := newService("fifo-test") require.NoError(t, err) t.Cleanup(s.cancel) s.rootCtx = context.Background() s.sandbox = &vcmock.Sandbox{MockID: "fifo-test"} c, err := newContainer(s, &taskAPI.CreateTaskRequest{ID: "container"}, vc.PodContainer, nil, false) require.NoError(t, err) s.containers[c.id] = c host, err := newTtyIO(context.Background(), "", "", path, …

内容来源: kata-containers/kata-containers