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

`F_SETFL(O_NONBLOCK)` in a child does not reach the parent's fd for the same pipe

Đang mở
#428 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
35/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
Lĩnh vực
operating-systems

Hướng nghiên cứu

Start with fd_apply_guest_nonblock and fd_entry_t.linux_flags in src/syscall/fdtable.c, then the fd_host_flag_mask check, to see how guest status flags are stored per process after fork. The reproducer in the issue shows the parent's read returning EINTR instead of EAGAIN; src/syscall/net-msg.c has the related SCM_RIGHTS comment. Done means the parent sees the child's O_NONBLOCK change, confirmed by running the reproducer, with the design choice for the other status flags settled.

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

Mô tả

bug

A fork leaves parent and child with fds for one open file description. Linux keeps the status flags there, so F_SETFL through either fd changes what both see.

elfuse sets O_NONBLOCK on every host pipe and socket it opens and keeps the guest's own O_NONBLOCK in fd_entry_t.linux_flags (fd_apply_guest_nonblock, src/syscall/fdtable.c). Fork copies that table to the child, and from then on each process changes its own copy.

Reproducer:

#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>

static void on_alarm(int signo)
{
    (void) signo;
}

int main(void)
{
    int p[2];
    char c;
    struct sigaction sa = {.sa_handler = on_alarm};
    sigaction(SIGALRM, &sa, NULL);
    pipe(p);

    if (fork() == 0) {
        fcntl(p[0], F_SETFL, fcntl(p[0], F_GETFL) | O_NONBLOCK);
        _exit(0);
    }
    wait(NULL);

    int nonblock = (fcntl(p[0], F_GETFL) & O_NONBLOCK) != 0;
    alarm(1);
    errno = 0;
    long r = read(p[0], &c, 1);
    printf("O_NONBLOCK in the parent=%d read=%ld errno=%d\n", nonblock, r,
           errno);
    return 0;
}
O_NONBLOCK in the parent read on the empty pipe
elfuse b57f367 0 waits until SIGALRM 1 s later, then EINTR
Linux 6.12 under qemu 1 EAGAIN at once

The same field holds every status flag elfuse answers without asking the host (fd_host_flag_mask), so O_ASYNC, O_DIRECT and O_NOATIME are per process as well. Only O_NONBLOCK was measured. The comment on a descriptor received over SCM_RIGHTS in src/syscall/net-msg.c states the same limit for that path.

Ngôn ngữ chính
C
Star
273
Fork
29
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.