Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`tee` returns `EINVAL` for every pair of pipes

Đang mở
#429 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
40/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c, linux, macos
Lĩnh vực
operating-systems

Hướng nghiên cứu

Start in sys_tee in src/syscall/io.c, where the early EINVAL return and its comment explain why copying without consuming is refused on macOS. The reproducer in the issue shows the target behaviour: tee should return the byte count, leave the source pipe readable, and copy into the destination. Done means that reproducer prints tee=5 errno=0 with both reads returning 5 bytes. Expect to find a workable approach to peeking a pipe on macOS first, which is the hard part.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

sys_tee (src/syscall/io.c) returns EINVAL without looking at its arguments. Its comment gives the reason: copying without consuming needs a way to look into a pipe, and macOS offers none.

Reproducer:

#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

int main(void)
{
    int in[2], out[2];
    char buf[8];
    pipe(in);
    pipe(out);
    write(in[1], "hello", 5);

    errno = 0;
    long n = tee(in[0], out[1], 100, SPLICE_F_NONBLOCK);
    printf("tee=%ld errno=%d\n", n, errno);
    if (n > 0)
        printf("copied=%zd still in the source=%zd\n",
               read(out[0], buf, sizeof(buf)), read(in[0], buf, sizeof(buf)));
    return 0;
}
result
elfuse b57f367 tee=-1 errno=22
Linux 6.12 under qemu tee=5 errno=0, then copied=5 still in the source=5

EINVAL is what tee(2) documents for descriptors that are not both pipes, so that is how a guest reads the refusal.

Ngôn ngữ chính
C
Star
271
Fork
28
Merge trung bình
2 ngày 17 giờ
Pull request đã merge (30 ngày)
17

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của sysprog21/elfuse

Tất cả issue của sysprog21/elfuse

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.